Definition in file mace-macros.h.
#include "RandomUtil.h"
#include "LogIdSet.h"


Go to the source code of this file.
Defines | |
| #define | MAX_LOG UINT_MAX |
| used to compile out logs -- disabling those at or above MAX_LOG | |
| #define | MSEC *1000 |
| convenience macro for milliseconds (in microseconds) | |
| #define | SEC *1000 MSEC |
| convenience macro for seocnds (in microseconds) | |
| #define | upcallAllVoid(func, args...) |
| passes args to upcall func for each registered handler, used with methods that return void. | |
| #define | upcallAll(var, ag, func, args...) |
| passes args to upcall func for each registered handler, combining the results using ag | |
| #define | andEq(x, y) x = x && y |
| convenience macro for an upcallAll which should and the results | |
| #define | orEq(x, y) x = x || y |
| convenience macro for an upcallAll which should or the results | |
| #define | ADD_LOG_BACKING |
| Internal. Used by generated code to prepare the backing for logs. | |
| #define | ADD_SELECTORS(x) |
| Prepares a method for logging using standard macros. | |
| #define | ADD_FUNC_SELECTORS ADD_SELECTORS(__PRETTY_FUNCTION__) |
| A version of ADD_SELECTORS(x) which uses __PRETTY_FUNCTION__ as the selector base. | |
| #define | PREPARE_FUNCTION uint64_t _curtime __attribute__((unused)) = 0; \ |
| Internal. Used by generated code to prepare functions for the curtime macro. | |
| #define | maceDebug(pri, args...) do { if(pri < MAX_LOG) { Log::logf(selectorId->debug, pri, args); } } while(0) |
| printf style debug message | |
| #define | maceLog(args...) |
| printf style log message | |
| #define | maceWarn(args...) |
| printf style warning message | |
| #define | maceError(args...) |
| printf style error message | |
| #define | maceCompiler(pri, args...) do { if(pri < MAX_LOG) { Log::logf(selectorId->compiler, pri, args); } } while(0) |
| printf style compiler generated message | |
| #define | maceout (_maceout == NULL? *(_maceout = &Log::log((0 != MAX_LOG?selectorId->log:Log::NULL_ID))): *_maceout) |
| output stream based log. Flush and output with << Log::endl | |
| #define | macedbg(pri) (pri < 6? (_macedbg[pri] == NULL? *(_macedbg[pri] = &Log::log((pri < MAX_LOG?selectorId->debug:Log::NULL_ID), (log_level_t)pri)): *_macedbg[pri]): Log::log((pri < MAX_LOG?selectorId->debug:Log::NULL_ID), (log_level_t)pri)) |
| output stream based debug. requires log level parameter. Flush and output with << Log::endl | |
| #define | macewarn (_macewarn == NULL? *(_macewarn = &Log::log((0 != MAX_LOG?selectorId->warn:Log::NULL_ID))): *_macewarn) |
| output stream based warning. Flush and output with << Log::endl | |
| #define | maceerr (_maceerr == NULL? *(_maceerr = &Log::log((0 != MAX_LOG?selectorId->error:Log::NULL_ID))): *_maceerr) |
| output stream based error. Flush and output with << Log::endl | |
| #define | macecompiler(pri) (pri < 2? (_macecompiler[pri] == NULL? *(_macecompiler[pri] = &Log::log((pri < MAX_LOG?selectorId->compiler:Log::NULL_ID), (log_level_t)pri)): *_macecompiler[pri]): Log::log((pri < MAX_LOG?selectorId->compiler:Log::NULL_ID), (log_level_t)pri)) |
| output stream based compiler generated message. requires log level parameter. Flush and output with << Log::endl | |
| #define | curtime (_curtime==0?(_curtime=TimeUtil::timeu()):_curtime) |
| Returns the current time of day, but the same value multiple times in a method. | |
| #define | EXPECT(x) if(!(x)) { maceerr << "EXPECT_FAILURE: Condition " << #x << " failed!" << Log::endl; } else |
| Prints warning if condition fails, allows optional success block. | |
Functions | |
| int | randint (int x) |
| convenience method for getting a random integer instead of RandomUtil::randInt(uint32_t) | |
| #define ADD_SELECTORS | ( | x | ) |
Value:
static const std::string selector = x; \ static const LogIdSet* const selectorId __attribute((unused)) = new LogIdSet(selector); \ static const log_id_t __trace_selector __attribute((unused)) = Log::getTraceId(x); \ ADD_LOG_BACKING
Not needed within Mace services.
| x | The string to use as the base string for the selectors |
Definition at line 113 of file mace-macros.h.
Referenced by ThreadUtil::broadcast(), HashUtil::computeFileHash(), ThreadUtil::create(), Accumulator::dumpAll(), VMRSSLimit::expire(), Util::getAddr(), BufferedBlockManager::getBlock(), ThreadUtil::lock(), ScopedSerialize< STRING, ORIGIN >::ScopedSerialize(), ThreadUtil::signal(), ThreadUtil::unlock(), VMRSSLimit::VMRSSLimit(), and ThreadUtil::wait().
| #define EXPECT | ( | x | ) | if(!(x)) { maceerr << "EXPECT_FAILURE: Condition " << #x << " failed!" << Log::endl; } else |
Prints warning if condition fails, allows optional success block.
example:
EXPECT(x != 0) { return y/x; } return 0;
or
EXPECT(x > 2); return x-2;
Definition at line 198 of file mace-macros.h.
| #define maceCompiler | ( | pri, | |||
| args... | ) | do { if(pri < MAX_LOG) { Log::logf(selectorId->compiler, pri, args); } } while(0) |
printf style compiler generated message
| pri | log level | |
| args | arguments to printf |
Definition at line 162 of file mace-macros.h.
| #define maceDebug | ( | pri, | |||
| args... | ) | do { if(pri < MAX_LOG) { Log::logf(selectorId->debug, pri, args); } } while(0) |
printf style debug message
| pri | log level | |
| args | arguments to printf |
Definition at line 132 of file mace-macros.h.
Referenced by bitmap_digest::insert().
| #define maceError | ( | args... | ) |
printf style error message
| args | arguments to printf |
Definition at line 155 of file mace-macros.h.
Referenced by VMRSSLimit::expire().
| #define maceLog | ( | args... | ) |
printf style log message
| args | arguments to printf |
Definition at line 153 of file mace-macros.h.
Referenced by Accumulator::dumpAll(), VMRSSLimit::expire(), NumberGen::Instance(), and VMRSSLimit::VMRSSLimit().
| #define maceWarn | ( | args... | ) |
printf style warning message
| args | arguments to printf |
Definition at line 154 of file mace-macros.h.
| #define upcallAll | ( | var, | |||
| ag, | |||||
| func, | |||||
| args... | ) |
Value:
for(std::map<int, typeof_upcall_##func*>::iterator _m_i = map_typeof_upcall_##func.begin(); \ _m_i != map_typeof_upcall_##func.end(); _m_i++) { \ ag(var, upcall_##func(args, _m_i->first)); \ }
| var | the variable to store the result in | |
| ag | the function to pairwise combine return values in var | |
| func | the upcall to make | |
| args | the arguments to pass to func, less the registration_uid_t |
Definition at line 88 of file mace-macros.h.
| #define upcallAllVoid | ( | func, | |||
| args... | ) |
Value:
for(std::map<int, typeof_upcall_##func*>::iterator _m_i = map_typeof_upcall_##func.begin(); \ _m_i != map_typeof_upcall_##func.end(); _m_i++) { \ upcall_##func(args, _m_i->first); \ }
| func | the upcall to make | |
| args | the arguments to pass to func, less the registration_uid_t |
Definition at line 73 of file mace-macros.h.
1.5.5