8#ifndef INCLUDED_BALL_LOG
9#define INCLUDED_BALL_LOG
1005#include <balscm_version.h>
1019#include <bsl_ostream.h>
1027#define BALL_LOG_CATEGORY \
1028 (ball_log_getCategoryHolder(BALL_LOG_CATEGORYHOLDER)->category())
1030#define BALL_LOG_THRESHOLD \
1031 (ball_log_getCategoryHolder(BALL_LOG_CATEGORYHOLDER)->threshold())
1033#define BALL_LOG_RECORD (ball_log_lOg_StReAm.record())
1035#define BALL_LOG_OUTPUT_STREAM (ball_log_lOg_StReAm.stream())
1041#define BALL_LOG_SET_CATEGORY(CATEGORY) \
1042 static BloombergLP::ball::CategoryHolder BALL_LOG_CATEGORYHOLDER = { \
1043 { BloombergLP::ball::CategoryHolder::e_UNINITIALIZED_CATEGORY }, \
1046 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(!BALL_LOG_CATEGORY)) { \
1047 BSLS_PERFORMANCEHINT_UNLIKELY_HINT; \
1048 BloombergLP::ball::Log::setCategory(&BALL_LOG_CATEGORYHOLDER, \
1052#define BALL_LOG_SET_CATEGORY_HIERARCHICALLY(CATEGORY) \
1053 static BloombergLP::ball::CategoryHolder BALL_LOG_CATEGORYHOLDER = { \
1054 { BloombergLP::ball::CategoryHolder::e_UNINITIALIZED_CATEGORY }, \
1057 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(!BALL_LOG_CATEGORY)) { \
1058 BSLS_PERFORMANCEHINT_UNLIKELY_HINT; \
1059 BloombergLP::ball::Log::setCategoryHierarchically( \
1060 &BALL_LOG_CATEGORYHOLDER, \
1064#define BALL_LOG_SET_DYNAMIC_CATEGORY(CATEGORY) \
1065 const BloombergLP::ball::Category *BALL_LOG_DYNAMIC_CATEGORY = \
1066 BloombergLP::ball::Log::setCategory(CATEGORY); \
1067 BloombergLP::ball::CategoryHolder BALL_LOG_CATEGORYHOLDER = { \
1068 { BloombergLP::ball::CategoryHolder::e_DYNAMIC_CATEGORY }, \
1069 { const_cast<BloombergLP::ball::Category *>( \
1070 BALL_LOG_DYNAMIC_CATEGORY) }, \
1074#define BALL_LOG_SET_DYNAMIC_CATEGORY_HIERARCHICALLY(CATEGORY) \
1075 const BloombergLP::ball::Category *BALL_LOG_DYNAMIC_CATEGORY = \
1076 BloombergLP::ball::Log::setCategoryHierarchically(CATEGORY); \
1077 BloombergLP::ball::CategoryHolder BALL_LOG_CATEGORYHOLDER = { \
1078 { BloombergLP::ball::CategoryHolder::e_DYNAMIC_CATEGORY }, \
1079 { const_cast<BloombergLP::ball::Category *>( \
1080 BALL_LOG_DYNAMIC_CATEGORY) }, \
1088#define BALL_LOG_SET_CLASS_CATEGORY(CATEGORY) \
1090 const BloombergLP::ball::CategoryHolder *ball_log_getCategoryHolder( \
1091 const BloombergLP::ball::CategoryHolder& categoryHolder) \
1093 return &categoryHolder; \
1096 const BloombergLP::ball::CategoryHolder *ball_log_getCategoryHolder(int) \
1098 static BloombergLP::ball::CategoryHolder holder = { \
1099 { BloombergLP::ball::CategoryHolder::e_UNINITIALIZED_CATEGORY }, \
1102 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(!holder.category())) { \
1103 BSLS_PERFORMANCEHINT_UNLIKELY_HINT; \
1104 BloombergLP::ball::Log::setCategory(&holder, CATEGORY); \
1108 enum { BALL_LOG_CATEGORYHOLDER = 0 }
1110#define BALL_LOG_SET_CLASS_CATEGORY_HIERARCHICALLY(CATEGORY) \
1112 const BloombergLP::ball::CategoryHolder *ball_log_getCategoryHolder( \
1113 const BloombergLP::ball::CategoryHolder& categoryHolder) \
1115 return &categoryHolder; \
1118 const BloombergLP::ball::CategoryHolder *ball_log_getCategoryHolder(int) \
1120 static BloombergLP::ball::CategoryHolder holder = { \
1121 { BloombergLP::ball::CategoryHolder::e_UNINITIALIZED_CATEGORY }, \
1124 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(!holder.category())) { \
1125 BSLS_PERFORMANCEHINT_UNLIKELY_HINT; \
1126 BloombergLP::ball::Log::setCategoryHierarchically(&holder, \
1131 enum { BALL_LOG_CATEGORYHOLDER = 0 }
1137#define BALL_LOG_SET_NAMESPACE_CATEGORY(CATEGORY) \
1140 const BloombergLP::ball::CategoryHolder *ball_log_getCategoryHolder(int) \
1142 static BloombergLP::ball::CategoryHolder holder = { \
1143 { BloombergLP::ball::CategoryHolder::e_UNINITIALIZED_CATEGORY }, \
1146 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(!holder.category())) { \
1147 BSLS_PERFORMANCEHINT_UNLIKELY_HINT; \
1148 BloombergLP::ball::Log::setCategory(&holder, CATEGORY); \
1152 enum { BALL_LOG_CATEGORYHOLDER = 0 }; \
1155#define BALL_LOG_SET_NAMESPACE_CATEGORY_HIERARCHICALLY(CATEGORY) \
1158 const BloombergLP::ball::CategoryHolder *ball_log_getCategoryHolder(int) \
1160 static BloombergLP::ball::CategoryHolder holder = { \
1161 { BloombergLP::ball::CategoryHolder::e_UNINITIALIZED_CATEGORY }, \
1164 if (BSLS_PERFORMANCEHINT_PREDICT_UNLIKELY(!holder.category())) { \
1165 BSLS_PERFORMANCEHINT_UNLIKELY_HINT; \
1166 BloombergLP::ball::Log::setCategoryHierarchically(&holder, \
1171 enum { BALL_LOG_CATEGORYHOLDER = 0 }; \
1181#define BALL_LOG_STREAM_CONST_IMP(SEVERITY) \
1182for (const BloombergLP::ball::CategoryHolder *ball_log_cAtEgOrYhOlDeR = \
1183 BloombergLP::ball::Log::categoryHolderIfEnabled<(SEVERITY)>( \
1184 ball_log_getCategoryHolder(BALL_LOG_CATEGORYHOLDER)); \
1185 ball_log_cAtEgOrYhOlDeR; \
1187for (BloombergLP::ball::Log_Stream ball_log_lOg_StReAm( \
1188 ball_log_cAtEgOrYhOlDeR->category(), \
1192 ball_log_cAtEgOrYhOlDeR; \
1193 ball_log_cAtEgOrYhOlDeR = 0)
1198#define BALL_LOG_STREAM_IMP(SEVERITY) \
1199for (const BloombergLP::ball::CategoryHolder *ball_log_cAtEgOrYhOlDeR = \
1200 ball_log_getCategoryHolder(BALL_LOG_CATEGORYHOLDER); \
1201 ball_log_cAtEgOrYhOlDeR \
1202 && ball_log_cAtEgOrYhOlDeR->threshold() >= (SEVERITY) \
1203 && BloombergLP::ball::Log::isCategoryEnabled(ball_log_cAtEgOrYhOlDeR, \
1206for (BloombergLP::ball::Log_Stream ball_log_lOg_StReAm( \
1207 ball_log_cAtEgOrYhOlDeR->category(), \
1211 ball_log_cAtEgOrYhOlDeR; \
1212 ball_log_cAtEgOrYhOlDeR = 0)
1218#define BALL_LOG_STREAM(SEVERITY) \
1219 BALL_LOG_STREAM_IMP((SEVERITY)) BALL_LOG_OUTPUT_STREAM
1221#define BALL_LOG_TRACE \
1222 BALL_LOG_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_TRACE) \
1223 BALL_LOG_OUTPUT_STREAM
1225#define BALL_LOG_DEBUG \
1226 BALL_LOG_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_DEBUG) \
1227 BALL_LOG_OUTPUT_STREAM
1229#define BALL_LOG_INFO \
1230 BALL_LOG_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_INFO) \
1231 BALL_LOG_OUTPUT_STREAM
1233#define BALL_LOG_WARN \
1234 BALL_LOG_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_WARN) \
1235 BALL_LOG_OUTPUT_STREAM
1237#define BALL_LOG_ERROR \
1238 BALL_LOG_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_ERROR) \
1239 BALL_LOG_OUTPUT_STREAM
1241#define BALL_LOG_FATAL \
1242 BALL_LOG_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_FATAL) \
1243 BALL_LOG_OUTPUT_STREAM
1245#define BALL_LOG_STREAM_BLOCK(SEVERITY) BALL_LOG_STREAM_IMP((SEVERITY))
1247#define BALL_LOG_TRACE_BLOCK \
1248 BALL_LOG_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_TRACE)
1250#define BALL_LOG_DEBUG_BLOCK \
1251 BALL_LOG_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_DEBUG)
1253#define BALL_LOG_INFO_BLOCK \
1254 BALL_LOG_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_INFO)
1256#define BALL_LOG_WARN_BLOCK \
1257 BALL_LOG_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_WARN)
1259#define BALL_LOG_ERROR_BLOCK \
1260 BALL_LOG_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_ERROR)
1262#define BALL_LOG_FATAL_BLOCK \
1263 BALL_LOG_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_FATAL)
1265#define BALL_LOG_END ""
1274#define BALL_LOGCB_STREAM_CONST_IMP(SEVERITY, CALLBACK) \
1275for (const BloombergLP::ball::CategoryHolder *ball_log_cAtEgOrYhOlDeR = \
1276 BloombergLP::ball::Log::categoryHolderIfEnabled<(SEVERITY)>( \
1277 ball_log_getCategoryHolder(BALL_LOG_CATEGORYHOLDER)); \
1278 ball_log_cAtEgOrYhOlDeR; \
1280for (BloombergLP::ball::Log_Stream ball_log_lOg_StReAm( \
1281 ball_log_cAtEgOrYhOlDeR->category(), \
1285 ball_log_cAtEgOrYhOlDeR \
1286 && (CALLBACK(&BALL_LOG_RECORD->customFields()), true); \
1287 ball_log_cAtEgOrYhOlDeR = 0)
1292#define BALL_LOGCB_STREAM_IMP(SEVERITY, CALLBACK) \
1293for (const BloombergLP::ball::CategoryHolder *ball_log_cAtEgOrYhOlDeR = \
1294 ball_log_getCategoryHolder(BALL_LOG_CATEGORYHOLDER); \
1295 ball_log_cAtEgOrYhOlDeR \
1296 && ball_log_cAtEgOrYhOlDeR->threshold() >= (SEVERITY) \
1297 && BloombergLP::ball::Log::isCategoryEnabled(ball_log_cAtEgOrYhOlDeR, \
1300for (BloombergLP::ball::Log_Stream ball_log_lOg_StReAm( \
1301 ball_log_cAtEgOrYhOlDeR->category(), \
1305 ball_log_cAtEgOrYhOlDeR \
1306 && (CALLBACK(&BALL_LOG_RECORD->customFields()), true); \
1307 ball_log_cAtEgOrYhOlDeR = 0)
1313#define BALL_LOGCB_STREAM(BALL_SEVERITY, CALLBACK) \
1314 BALL_LOGCB_STREAM_IMP((BALL_SEVERITY), (CALLBACK)) BALL_LOG_OUTPUT_STREAM
1316#define BALL_LOGCB_TRACE(CALLBACK) \
1317 BALL_LOGCB_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_TRACE, \
1319 BALL_LOG_OUTPUT_STREAM
1321#define BALL_LOGCB_DEBUG(CALLBACK) \
1322 BALL_LOGCB_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_DEBUG, \
1324 BALL_LOG_OUTPUT_STREAM
1326#define BALL_LOGCB_INFO(CALLBACK) \
1327 BALL_LOGCB_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_INFO, \
1329 BALL_LOG_OUTPUT_STREAM
1331#define BALL_LOGCB_WARN(CALLBACK) \
1332 BALL_LOGCB_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_WARN, \
1334 BALL_LOG_OUTPUT_STREAM
1336#define BALL_LOGCB_ERROR(CALLBACK) \
1337 BALL_LOGCB_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_ERROR, \
1339 BALL_LOG_OUTPUT_STREAM
1341#define BALL_LOGCB_FATAL(CALLBACK) \
1342 BALL_LOGCB_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_FATAL, \
1344 BALL_LOG_OUTPUT_STREAM
1346#define BALL_LOGCB_STREAM_BLOCK(BALL_SEVERITY, CALLBACK) \
1347 BALL_LOGCB_STREAM_IMP((BALL_SEVERITY), (CALLBACK))
1349#define BALL_LOGCB_TRACE_BLOCK(CALLBACK) \
1350 BALL_LOGCB_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_TRACE, \
1353#define BALL_LOGCB_DEBUG_BLOCK(CALLBACK) \
1354 BALL_LOGCB_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_DEBUG, \
1357#define BALL_LOGCB_INFO_BLOCK(CALLBACK) \
1358 BALL_LOGCB_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_INFO, \
1361#define BALL_LOGCB_WARN_BLOCK(CALLBACK) \
1362 BALL_LOGCB_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_WARN, \
1365#define BALL_LOGCB_ERROR_BLOCK(CALLBACK) \
1366 BALL_LOGCB_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_ERROR, \
1369#define BALL_LOGCB_FATAL_BLOCK(CALLBACK) \
1370 BALL_LOGCB_STREAM_CONST_IMP(BloombergLP::ball::Severity::e_FATAL, \
1373#define BALL_LOGCB_END ""
1382#define BALL_LOGVA_CONST_IMP(SEVERITY, ...) \
1384 if (const BloombergLP::ball::CategoryHolder *ball_log_cAtEgOrYhOlDeR = \
1385 BloombergLP::ball::Log::categoryHolderIfEnabled<(SEVERITY)>( \
1386 ball_log_getCategoryHolder(BALL_LOG_CATEGORYHOLDER))) { \
1387 BloombergLP::ball::Log_Formatter ball_log_fOrMaTtEr( \
1388 ball_log_cAtEgOrYhOlDeR->category(), \
1392 BloombergLP::ball::Log::format(ball_log_fOrMaTtEr.messageBuffer(), \
1393 ball_log_fOrMaTtEr.messageBufferLen(), \
1405#define BALL_LOGVA(SEVERITY, ...) \
1407 const BloombergLP::ball::CategoryHolder *ball_log_cAtEgOrYhOlDeR = \
1408 ball_log_getCategoryHolder(BALL_LOG_CATEGORYHOLDER); \
1409 if (ball_log_cAtEgOrYhOlDeR->threshold() >= (SEVERITY) && \
1410 BloombergLP::ball::Log::isCategoryEnabled(ball_log_cAtEgOrYhOlDeR, \
1412 BloombergLP::ball::Log_Formatter ball_log_fOrMaTtEr( \
1413 ball_log_cAtEgOrYhOlDeR->category(), \
1417 BloombergLP::ball::Log::format(ball_log_fOrMaTtEr.messageBuffer(), \
1418 ball_log_fOrMaTtEr.messageBufferLen(), \
1423#define BALL_LOGVA_TRACE(...) \
1424 BALL_LOGVA_CONST_IMP(BloombergLP::ball::Severity::e_TRACE, __VA_ARGS__)
1426#define BALL_LOGVA_DEBUG(...) \
1427 BALL_LOGVA_CONST_IMP(BloombergLP::ball::Severity::e_DEBUG, __VA_ARGS__)
1429#define BALL_LOGVA_INFO( ...) \
1430 BALL_LOGVA_CONST_IMP(BloombergLP::ball::Severity::e_INFO, __VA_ARGS__)
1432#define BALL_LOGVA_WARN( ...) \
1433 BALL_LOGVA_CONST_IMP(BloombergLP::ball::Severity::e_WARN, __VA_ARGS__)
1435#define BALL_LOGVA_ERROR(...) \
1436 BALL_LOGVA_CONST_IMP(BloombergLP::ball::Severity::e_ERROR, __VA_ARGS__)
1438#define BALL_LOGVA_FATAL(...) \
1439 BALL_LOGVA_CONST_IMP(BloombergLP::ball::Severity::e_FATAL, __VA_ARGS__)
1445#define BALL_LOG_IS_ENABLED(SEVERITY) \
1446 ((BALL_LOG_THRESHOLD >= (SEVERITY)) \
1447 && BloombergLP::ball::Log::isCategoryEnabled( \
1448 ball_log_getCategoryHolder(BALL_LOG_CATEGORYHOLDER), \
1474 const BloombergLP::ball::CategoryHolder& categoryHolder)
1476 return &categoryHolder;
1508 bsl::size_t numBytes,
1521 const
char *fileName,
1545 const
char *fileName,
1547 const
char *message);
1615 template <
int t_SEVERITY>
1629 const
char *categoryName);
1666 const
char *categoryName);
1704 const int d_severity;
1719 const char *fileName,
1738 bsl::ostream& stream();
1749 const
Record *record() const;
1752 int severity() const;
1783 const int d_severity;
1804 const char *fileName,
1818 char *messageBuffer();
1833 int messageBufferLen()
const;
1838 const Record *record()
const;
1841 int severity()
const;
1853template <
int t_SEVERITY>
1868 return categoryHolder;
1879 categoryHolder->
threshold() >= t_SEVERITY)) {
1886 return categoryHolder;
1921 return d_category_p;
1944 return d_buffer.get();
1957 return d_category_p;
Definition ball_category.h:362
int threshold() const
Return the threshold level held by this holder.
Definition ball_category.h:616
Definition ball_category.h:184
Definition ball_log.h:1696
bsl::ostream & stream()
Definition ball_log.h:1912
const Category * category() const
Definition ball_log.h:1919
~Log_Stream() BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(false)
Record * record()
Definition ball_log.h:1906
int severity() const
Return the severity held by this logging stream.
Definition ball_log.h:1931
Log_Stream(const Category *category, const char *fileName, int lineNumber, int severity)
bsl::ostream & messageStream()
Definition ball_recordattributes.h:538
Definition ball_record.h:178
RecordAttributes & fixedFields()
Return the modifiable fixed fields of this log record.
Definition ball_record.h:396
Definition bslma_managedptr.h:1182
#define BSLS_ANNOTATION_PRINTF(fmt, arg)
Definition bsls_annotation.h:353
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_NOEXCEPT_SPECIFICATION(...)
Definition bsls_keyword.h:634
Definition ball_administration.h:214
const BloombergLP::ball::CategoryHolder * ball_log_getCategoryHolder(const BloombergLP::ball::CategoryHolder &categoryHolder)
Definition ball_log.h:1473
Definition bdlb_printmethods.h:283
Definition balxml_encoderoptions.h:68
Definition bslmt_barrier.h:344
Definition ball_log.h:1490
static int static Record * getRecord(const Category *category, const char *fileName, int lineNumber)
static void releaseMessageBuffer(bslmt::Mutex *mutex)
static void logMessage(const Category *category, int severity, const char *fileName, int lineNumber, const char *message)
static const CategoryHolder * categoryHolderIfEnabled(const CategoryHolder *categoryHolder)
Definition ball_log.h:1855
static int format(char *buffer, bsl::size_t numBytes, const char *format,...) BSLS_ANNOTATION_PRINTF(3
static bool isCategoryEnabled(const CategoryHolder *categoryHolder, int severity)
static const Category * setCategory(const char *categoryName)
static char * obtainMessageBuffer(bslmt::Mutex **mutex, int *bufferSize)
static const Category * setCategoryHierarchically(const char *categoryName)
Definition ball_log.h:1895
@ e_INFO
Definition ball_severity.h:172