FARGOS/VISTA Object Management Environment Core  ..
FARGOS/VISTA Object Management Environment Core Table of Contents
logging_api.hpp
Go to the documentation of this file.
1 #ifndef _LOGGING_API_HPP_
2 #define _LOGGING_API_HPP_ "$Id: logging_api.hpp 456 2020-07-23 20:25:49Z geoff $"
4 
6 /*
7  * Copyright (C) 2010 - 2020 FARGOS Development, LLC
8  * Author: Geoff Carpenter - http://www.fargos.net/gcc.html
9  */
10 
48 // Include headers needed for convenience templates related to networking
49 #ifdef _WIN32
50 #ifndef _WIN32_WINNT
51 #define _WIN32_WINNT 0x0600
52 #else
53 #if _WIN32_WINNT < 0x0600
54 #warning "Need to support Windows Vista or later for inet_ntop() support"
55 #endif
56 #endif
57 #include <winsock2.h>
58 #include <ws2tcpip.h>
59 /* end ifdef _WIN32 */
60 #else
61 #include <arpa/inet.h>
62 #include <sys/socket.h>
63 #include <sys/un.h>
64 #endif
65 
67 #include <stdint.h>
68 #include <memory.h>
69 
74 #include <iostream>
75 
89 #ifndef USE_GETTID_FOR_THREADID
90 #define USE_GETTID_FOR_THREADID 0
91 #endif
92 #if __linux__ && USE_GETTID_FOR_THREADID == 1
93 #include <sys/syscall.h>
94 #endif
95 
96 #ifndef COMPILE_DEBUG_LEVEL
97 #define COMPILE_DEBUG_LEVEL ~0
98 #endif
99 
100 #define DEFAULT_LOG_DIRECTORY_ENVIRONMENT_VARIABLE "LOGDIR"
101 
103 #define LOGFILE_BFR_MAGIC_NUMBER "LOGCBFR"
104 
105 typedef uint_fast32_t LogMaskPrimitiveType_t;
107 
111  /* TODO: progName could be changed to a char[52], keeping this block of info
112  * in a single cache line. Downsides are 1) initialization requires
113  * copying data and 2) a fixed limit on maximum program name would be
114  * set.
115  */
116  const char *programName;
117  uint32_t processID;
119  uint32_t defaultLogLevel;
120  uint32_t defaultLogPrefix;
121  unsigned char useThreads;
122  unsigned char enableMap;
123 };
124 
128 
135  // argument type has to be minimum of 16-bits
136  uint32_t argType;
137  uint32_t argLength;
138  uint32_t offsetNextArg;
139  unsigned char headerLen;
140  unsigned char _reserved[3]; // alignment, available for future use
141 };
142 
148  char asChars[8];
149  int32_t i32;
150  uint32_t u32;
151  int64_t i64;
152  uint64_t u64;
153  float f;
154  double d;
155  unsigned char bytes[8];
156  } value;
157 };
158 
163  unsigned char formatVersion;
164  /* \brief A value that denotes both byte order and floating point format.
165  */
166  unsigned char byteOrder;
167  unsigned char logPrefixMask;
168  unsigned char _reserved[1];
169  uint32_t logLineLength;
171  uint64_t threadId;
172 
173  uint32_t lineNumber;
174  uint32_t importanceLevel;
175 
176  uint32_t argumentCount;
177  uint32_t offsetFileName;
178 
180  uint32_t offsetFirstArg;
181  /* more fields can be added here, as earlier decoders will skip over
182  * the content and pick up the data from offsetFileName, offsetFormatString,
183  * and offsetFirstArg
184  */
185  /* implied field: fileName[offsetFormatString - offsetFileName] */
186  /* implied field: formatString[offsetFirstArg - offsetFormatString] */
187 };
188 
189 enum {
198 };
199 
202  char stringData[1];
203 };
204 
206 typedef const struct StringInROM_struct *StringInROM;
207 
211 #define SiR(x) ((StringInROM) (x))
212 
217 public:
218  const char *textBfr;
219  uint_fast32_t bfrLen;
220 
221  /* \brief Scan source block and clip length at first null character
222  *
223  * \param bfr points to a conventional C string
224  */
225  inline explicit TextBlock_struct(const char *bfr) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3") {
226  // with GNU_SOURCE, could replace with rawmemchr() call
227  textBfr = bfr;
228  bfrLen = (uint_fast32_t) strlen(bfr);
229  }
230 
231  /* Note block of known length and optionally clip output
232  * length at first null character.
233  *
234  * \param bfr points to the string
235  * \param len specifies the known length of the string
236  * \param clipAtNull is a Boolean that indicates if the
237  * string length should be clipped at the first null character
238  * encountered before the end of the block. If false,
239  * the block length is taken from \ref len.
240  */
241  inline TextBlock_struct(const char *bfr, uint_fast32_t len, bool clipAtNull=false) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3") {
242  textBfr = bfr;
243  if (clipAtNull == false) {
244  bfrLen = len;
245  } else {
246  // with GNU_SOURCE, could replace with strnlen() call
247  const char *end = (const char *) memchr(bfr, 0, len);
248  bfrLen = (end == nullptr) ? len : end - bfr;
249  }
250  }
251 }; // end TextBlock_struct
252 
253 
255 #define _DEFAULT_ESCAPED_CHARACTERS "\"\n\r\t\b\\"
256 #define _DEFAULT_REPLACEMENT_CHARACTERS "\\\"\0\\n\0\\r\0\\t\0\\b\0\\\\\0"
258 #define _DEFAULT_NULL_REPLACEMENT "\\0"
260 
272 public:
274  int8_t escapedLen[256];
276 
289  void initEscapes(const char *quoteTheseChars,
290  const char *escapeUsing, const char *convertNULL) OME_ALWAYS_INLINE
291  {
292  OME_PREFETCH(escapeUsing, 0, 0); // read-only, once only
293  memset(escapedLen, 0xff, sizeof(escapedLen)); // initialize with -1
294 
295  const char *start = escapeUsing;
296  uint_fast16_t quotableLen = 0;
297  do {
298  const unsigned char c = reinterpret_cast<const unsigned char *>(quoteTheseChars)[quotableLen];
299  if (c != '\0') {
300  uint_fast8_t i = 0;
301  while (*start != '\0') {
302  escapedChar[c][i] = *start;
303  start += 1;
304  i += 1;
305  }
306  escapedChar[c][i] = '\0';
307  escapedLen[c] = i;
308  start += 1; // skip null
309  }
310  quotableLen += 1;
311  } while (quoteTheseChars[quotableLen] != '\0');
312  if (convertNULL != nullptr) {
313  OME_PREFETCH(convertNULL, 0, 0); // read-only, once only
314  start = convertNULL;
315  uint_fast8_t i = 0;
316  while (*start != '\0') {
317  escapedChar[(unsigned char) '\0'][i] = *start;
318  start += 1;
319  i += 1;
320  }
321  escapedChar[(unsigned char) '\0'][i] = '\0';
322  escapedLen[(unsigned char ) '\0'] = i;
323  }
324  }
325 
333  explicit Escaped_Replacement_Characters(bool doNothing) {}
334 
344  const char *quoteTheseChars=_DEFAULT_ESCAPED_CHARACTERS,
345  const char *escapeUsing=_DEFAULT_REPLACEMENT_CHARACTERS,
346  const char *convertNULL=_DEFAULT_NULL_REPLACEMENT) OME_ALWAYS_INLINE {
347  initEscapes(quoteTheseChars, escapeUsing, convertNULL);
348  }
349 
350 }; // end Escaped_Replacement_Characters
351 
369 public:
372 
373  /* NOTE: escapedLen is examined for EVERY character in the string, so it
374  * is maintained as a dense array to maximize the amount of useful
375  * content held within a cache line.
376  * In contrast, escapedChar is only visited as needed to handle
377  * the exceptional cases, so it is maintained separately.
378  */
379  const char *textBfr;
380  uint_fast32_t bfrLen;
384 
385 #if 0
386 protected:
399  void initEscapes(const char *quoteTheseChars=_DEFAULT_ESCAPED_CHARACTERS,
400  const char *escapeUsing=_DEFAULT_REPLACEMENT_CHARACTERS,
401  const char *convertNULL=_DEFAULT_NULL_REPLACEMENT) OME_ALWAYS_INLINE
402  {
403  dynamicReplacements.initEscapes(quoteTheseChars, escapeUsing, convertNULL);
404  }
405 #endif
406 
407 public:
410  inline explicit EscapedTextBlock_struct(const char *bfr,
411  const char *quoteTheseChars,
412  const char *escapeUsing=_DEFAULT_REPLACEMENT_CHARACTERS,
413  const char *convertNULL=_DEFAULT_NULL_REPLACEMENT) OME_ALWAYS_INLINE :
415  dynamicReplacements(quoteTheseChars, escapeUsing, convertNULL)
416  {
417  textBfr = bfr;
418  bfrLen = (uint_fast32_t) strlen(bfr);
419  }
420 
426  inline explicit EscapedTextBlock_struct(const char *bfr,
428  replacementsToUse(&useReplacements),
429  dynamicReplacements(false)
430  {
431  textBfr = bfr;
432  bfrLen = (uint_fast32_t) strlen(bfr);
433  }
434 
438  inline EscapedTextBlock_struct(const char *bfr, uint_fast32_t len,
439  const char *quoteTheseChars,
440  const char *escapeUsing=_DEFAULT_REPLACEMENT_CHARACTERS,
441  const char *convertNULL=_DEFAULT_NULL_REPLACEMENT) OME_ALWAYS_INLINE :
443  dynamicReplacements(quoteTheseChars, escapeUsing, convertNULL)
444  {
445  textBfr = bfr;
446  bfrLen = len;
447  }
448 
452  inline EscapedTextBlock_struct(const char *bfr, uint_fast32_t len,
454  replacementsToUse(&useReplacements),
455  dynamicReplacements(false)
456  {
457  textBfr = bfr;
458  bfrLen = len;
459  }
460 
464  inline explicit EscapedTextBlock_struct(const std::string &bfr,
465  const char *quoteTheseChars,
466  const char *escapeUsing=_DEFAULT_REPLACEMENT_CHARACTERS,
467  const char *convertNULL=_DEFAULT_NULL_REPLACEMENT) OME_ALWAYS_INLINE :
469  dynamicReplacements(quoteTheseChars, escapeUsing, convertNULL)
470  {
471  textBfr = bfr.c_str();
472  bfrLen = (uint_fast32_t) bfr.size();
473  }
474 
478  inline explicit EscapedTextBlock_struct(const std::string &bfr,
480  replacementsToUse(&useReplacements),
481  dynamicReplacements(false)
482  {
483  textBfr = bfr.c_str();
484  bfrLen = (uint_fast32_t) bfr.size();
485  }
486 
490  inline explicit EscapedTextBlock_struct(const char justThisChar,
491  const char *quoteTheseChars,
492  const char *escapeUsing=_DEFAULT_REPLACEMENT_CHARACTERS,
493  const char *convertNULL=_DEFAULT_NULL_REPLACEMENT) OME_ALWAYS_INLINE :
495  dynamicReplacements(quoteTheseChars, escapeUsing, convertNULL)
496  {
497  singleOutputChar = justThisChar;
499  bfrLen = 1;
500  }
501 
502  inline explicit EscapedTextBlock_struct(const char justThisChar,
504  replacementsToUse(&useReplacements),
505  dynamicReplacements(false)
506  {
507  singleOutputChar = justThisChar;
509  bfrLen = 1;
510  }
511 
512 }; // end EscapedTextBlock_struct
513 
518 public:
519  const void *dataBfr;
520  uint_fast32_t bfrLen;
521 
522  inline BinaryBlock_struct(const void *bfr, uint_fast32_t len) OME_ALWAYS_INLINE {
523  dataBfr = bfr;
524  bfrLen = len;
525  }
526 }; // end BinaryBlock_struct
527 
533 public:
534  const void *dataBfr;
535  uint_fast32_t bfrLen;
537 
538  inline HexadecimalBlock_struct(const void *bfr, uint_fast32_t len,
539  bool useLowercase=true) OME_ALWAYS_INLINE {
540  dataBfr = bfr;
541  bfrLen = len;
542  asLowercase = useLowercase;
543  }
544 }; // end HexadecimalBlock_struct
545 
547 #define SUGGESTED_DEFAULT_MAX_LOG_LINES 1024
548 
549 
552 class LogManager {
553 public:
554  typedef void (* TimeAcquisitionFP)(struct timespec *, const LogManager *);
555 
556  static void defaultGetTime(struct timespec *timestamp, const LogManager *logMgr) {
557  interpolated_clock_gettime(timestamp, false);
558  }
559 private:
562  public:
563  const char *fileName;
565 
568  fileName = nullptr;
569  }
570 
571  }; // end private FileNameCacheEntry class
572 
573 protected:
574  enum {
576  // file name cache should be power-of-2 for best performance
578  };
579  /* These static arrays are shared across ALL LogManager instances
580  * within a process.
581  */
586 
593  static void initializePrefixTable();
594 
595  // TODO: a new constructor which allows a
596  // BufferRegion to be passed can be added.
599  const char *errorCondition;
600  size_t blockSize;
601  uint_fast32_t logPrefixMask;
607 public:
608  enum {
610  MAX_LOG_LINE_LENGTH=((16 * 4096) + (3 * 64)) // skewed slightly to avoid the same cache line
611  };
614  char logFileName[256]; // filled in by newLogFileForComponent()
615 
619 
620 private:
621  FileNameCacheEntry findCachedFileName(const char *fileName) const;
622 
623  void addCachedFileName(const char *fileNameKey, const TextBlock_struct entry);
624 
625 public:
626  void killProcessingThread() { // for debug only
628  }
629 
641  static uint_fast32_t addLogComponent(const char *componentName,
642  LogMaskType_t *maskLocation, LogMaskPrimitiveType_t initialMask=0);
643 
647  uint_fast32_t getLogPrefixMask() const OME_ALWAYS_INLINE {
648  return (logPrefixMask);
649  }
650 
663  inline uint_fast32_t setLogPrefixMask(uint_fast32_t newMask) OME_ALWAYS_INLINE {
664  uint_fast32_t original = logPrefixMask;
665  logPrefixMask = newMask;
666  return (original);
667  }
668 
669  /* \brief Set a fixed number of directory entries to be stripped
670  * from source file names when output in a log line. Default value is
671  * obtained from the GCOV_PREFIX_STRIP environment variable, if
672  * present; otherwise it defaults to 0.
673  */
674  void setStripLeadingDirectories(uint_fast32_t dirCount) {
675  stripLeadingDirectories = dirCount;
676  }
677 
713  static int initializeLogSubsystem(int *newArgc, const char **newArgv,
714  const int argc, const char *argv[],
715  const char *componentName=nullptr,
716  LogMaskType_t *appMaskLocation=nullptr,
717  const uint_fast32_t maxLines=128, const LogMaskPrimitiveType_t logPrefixMask=~0U);
718 
719  /* \brief Create a LogManager associated with an already open file descriptor.
720  */
723  uint_fast8_t useSeparateThreads, unsigned char *region, size_t bytes);
724 
755  SharedMemoryVariableNode *parentNode,
756  const char *app, uint_fast32_t filenameCreateFlags,
758  uint_fast8_t enableMap, uint_fast8_t useSeparateThreads,
759  size_t desiredRegionSize=0, size_t reserveAtEnd=0,
760  const char *inDir=getenv(DEFAULT_LOG_DIRECTORY_ENVIRONMENT_VARIABLE));
761 
775  static LogManager *newStandardLogFile(const char *namedComponent=nullptr,
776  LogMaskPrimitiveType_t filenameCreateFlags=~0U,
777  SharedMemoryVariableNode *parentNode=nullptr);
778 
782  return (bfrMgr);
783  }
784 
788  return (ioMgr);
789  }
790 
799  IO_Processor *controller);
800 
829  OS_HANDLE_TYPE output_fd, uint_fast8_t useSeparateThread,
830  const char *appName,
831  uint_fast32_t logLinePrefixMask=~0U,
832  uint_fast32_t maxLineSize=(LogManager::MAX_LOG_LINE_LENGTH - sizeof(SharedBufferAllocRecord)),
833  unsigned char *region=nullptr, size_t bytes=(LogManager::MAX_LOG_LINE_LENGTH * 64));
834 
835  virtual ~LogManager();
836 
838  int closeLog();
839 
848  {
850  return (result);
851  }
852 
858  bfrMgr->returnBlock(rec);
859  }
860 
872  size_t *bufferLen=nullptr) const OME_ALWAYS_INLINE {
873  // use IO_Processor context in case header
874  // is required before each block. As an optimization,
875  // we could assume no and use:
876  // if (bufferLen != nullptr) { *bufferLen = rec->usedLen; }
877  // return (bfrMgr->blockAddress(rec));
878  if (OME_EXPECT_TRUE(ioMgr != nullptr)) {
879  return (ioMgr->bufferAddress(rec, bufferLen));
880  }
881  // We don't have an IO_Processor associated with this
882  // LogManager, as would be the case for special formatting buffers.
883  if (bufferLen != nullptr) {
884  *bufferLen = rec->usedLen;
885  }
886  return (bfrMgr->blockAddress(rec));
887  }
888 
896 
906  const void *data, size_t len);
907 
916  ssize_t copyAndWriteData(const void *data, size_t len) {
918  ssize_t result = copyAndWriteDataToBuffer(rec, data, len);
919  return (result);
920  }
921 
926  const TextBlock_struct pruneDirectoryPrefix(const char *fileName, const int_fast32_t fileNameLen);
927 
932  const char *getErrorCondition() const OME_ALWAYS_INLINE {
933  return (errorCondition);
934  }
935 
938  void setErrorCondition(const char *messageText) OME_ALWAYS_INLINE {
939  errorCondition = messageText;
940  }
941 
948  if (routine != nullptr) {
949  getTimestampRoutine = routine;
950  } else {
952  }
953  }
954 
959  return (getTimestampRoutine);
960  }
961 
967  inline void getTimestamp(struct timespec *timestamp) const OME_ALWAYS_INLINE {
968  (*getTimestampRoutine)(timestamp, this);
969  }
970 
981  static void setSourceForCustomLogTime(POSIXtimeInNanoseconds *timeSource);
982 
991  static void returnCustomLogTime(struct timespec *timestamp, const LogManager *logMgr);
992 
993 
994 }; // end class LogManager
995 
1003 public:
1005  const char *name=nullptr, LogMaskPrimitiveType_t defaultMask=0) {
1006 #if 0
1007  if (defaultMask != 0) { // if we have a mask set, set it as initial default
1008  var = defaultMask;
1009  }
1010 #endif
1011  LogManager::addLogComponent(name, &var, defaultMask);
1012  }
1013 
1015 }; // end class AutoRegisterLogComponent
1016 
1017 
1023 #if __cplusplus >= 201100L
1024  final // not intended to be used as a base class
1025 #endif
1026 {
1027 public:
1028  enum {
1033  };
1034 
1044  };
1045 
1063  // reserve lower 4 bits for flags and attributes
1066  LOG_SEVERITY_INFO = (1 << 6),
1067  LOG_SEVERITY_WARN = (1 << 7),
1070  LOG_SEVERITY_USER = (1 << 10),
1074  };
1075 
1078  char asChars[sizeof(char *)];
1079  unsigned char bytes[sizeof(char *)];
1080  unsigned char uc;
1081  int32_t i32;
1082  uint32_t u32;
1083  int64_t i64;
1084  uint64_t u64;
1085  float f;
1086  double d;
1087  const void *ptr;
1088  const char *asCstring; // to coerce debugger into displaying content
1089  const unsigned char *asUCstring;
1090  };
1091 
1105  LOG_ARG_TYPE_POINTER=128,
1106  LOG_ARG_TYPE_ROM_TEXT = LOG_ARG_TYPE_POINTER | LOG_ARG_TYPE_TEXT,
1107  LOG_ARG_TYPE_TEXT_FRAGMENT = LOG_ARG_TYPE_POINTER | LOG_ARG_TYPE_CHAR,
1108  LOG_ARG_TYPE_HEX_FRAGMENT = LOG_ARG_TYPE_POINTER | LOG_ARG_TYPE_CHAR | LOG_ARG_TYPE_FLOAT,
1109  LOG_ARG_TYPE_HEX_FRAGMENT_UPPER = LOG_ARG_TYPE_POINTER | LOG_ARG_TYPE_CHAR | LOG_ARG_TYPE_DOUBLE,
1110  LOG_ARG_TYPE_POSIX_NANOSECONDS = 256 | LOG_ARG_TYPE_UINT64,
1111  LOG_ARG_TYPE_FIXED_POINT = 512 | LOG_ARG_TYPE_UINT64
1112  };
1120  typedef uint32_t LogArgumentLenType_t;
1121 
1123  const char *logLineFormat;
1124  const char *sourceFile;
1125  struct timespec timestamp;
1126  uint64_t threadId;
1128  uint32_t argCount;
1129  uint32_t sourceLine;
1130  uint32_t importanceLevel;
1131  uint32_t generatedOffset;
1133  char generatedFormatLine[LogManager::MAX_LOG_LINE_LENGTH - 4];
1134 
1139  } argList[LOG_MAX_ARGUMENT_TOTAL];
1140 
1152  static void splitLongLogLine(LogMessageRecord &context,
1153  const char *line, const char *separators=",;",
1154  size_t blockLength=LogManager::MAX_LOG_LINE_LENGTH);
1155 
1166  static int define_commandline_flag(const char *flagName,
1168  const char *label=nullptr);
1169 
1199  static int process_commandline_log_flags(LogSubsystemInfo *info,
1200  int argc, const char *argv[], int *newArgc, const char **newArgv);
1201 
1206  static TextBlock_struct getSeverityLabelWithLength(uint_fast32_t level);
1207 
1208  static const char *getSeverityLabel(uint_fast32_t level);
1209 
1210  LogMessageRecord(LogManager *mgr, uint32_t importanceFlags,
1211  const char *atFileName, uint32_t atLineNumber,
1212  int_fast32_t fileNameLen=-1) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3") {
1213  logMgr = mgr;
1214  argCount = 0;
1215  sourceFile = atFileName;
1216  if (OME_EXPECT_TRUE(fileNameLen != -1)) {
1217  sourceFileNameLen = fileNameLen;
1218  } else {
1219  if (OME_EXPECT_TRUE(atFileName != nullptr)) {
1220  sourceFileNameLen = strlen(atFileName);
1221  } else {
1222  sourceFileNameLen = 0;
1223  }
1224  }
1225  sourceLine = atLineNumber;
1226  importanceLevel = importanceFlags;
1227  logLineFormat = nullptr;
1228  generatedOffset = 0;
1229  argCountExceeded = 0;
1230 #ifndef _WIN32
1231 #if __linux__ && USE_GETTID_FOR_THREADID == 1
1232  threadId = (uint64_t) syscall(__NR_gettid); // invoke gettid()
1233 #else
1234  threadId = (uint64_t) pthread_self();
1235 #endif
1236 #else
1237  threadId = (uint64_t) GetCurrentThreadId();
1238 #endif
1239  logMgr->getTimestamp(&timestamp);
1240  }
1241 
1243 
1245  return (logMgr);
1246  }
1247 
1260  inline void setLogFormat(const char *f) OME_ALWAYS_INLINE {
1261  logLineFormat = f;
1262  // TODO: set generatedOffset as strlen(logLineFormat)
1263  }
1264 
1265  // TODO: make generateFormatString() protected rather than public
1273  int generateFormatString(unsigned int fieldNum) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3") {
1274  char *dest = generatedFormatLine + generatedOffset;
1275 
1276  ArgumentRecord &argRec = argList[fieldNum];
1277 
1278  switch (argRec.argBaseType) {
1279  case LOG_ARG_TYPE_POINTER:
1280  if (OME_EXPECT_TRUE(argRec.argLen != 0)) {
1281  memcpy(dest, "%B", 2);
1282  } else {
1283  memcpy(dest, "%p", 2);
1284  }
1285  dest += 2;
1286  break;
1287  case LOG_ARG_TYPE_TEXT_FRAGMENT:
1288  memcpy(dest, "%B", 2);
1289  dest += 2;
1290  break;
1291  case LOG_ARG_TYPE_HEX_FRAGMENT:
1292  memcpy(dest, "%x", 2);
1293  dest += 2;
1294  break;
1295  case LOG_ARG_TYPE_HEX_FRAGMENT_UPPER:
1296  memcpy(dest, "%X", 2);
1297  dest += 2;
1298  break;
1299  case LOG_ARG_TYPE_ROM_TEXT:
1300  if (OME_EXPECT_FALSE(argRec.argLen > MIN_IOV_UNIT_LEN)) { // more than threshold
1301  // remember its location for output later
1302  memcpy(dest, "%s", 2);
1303  dest += 2;
1304  break;
1305  }
1306  // Too few bytes to waste on an iovec entry
1307  // NOTE: FALL THROUGH AND TREAT AS TRANSIENT TEXT
1308  case LOG_ARG_TYPE_TEXT: { // string is copied to format string
1309  char *src = (char *) argRec.logArgs.ptr;
1310  // honor stored length argument
1311  for(uint_fast32_t _c=0;_c<argRec.argLen;_c+=1) {
1312  if (OME_EXPECT_FALSE(*src == '%')) { // escape formatting character ...
1313  *(dest++) = '%'; // ...by adding it twice
1314  }
1315  *(dest++) = *(src++);
1316  }
1317  argCount -= 1; // delete argument
1318  }
1319  break;
1320  case LOG_ARG_TYPE_CHAR:
1321  // Too few bytes to waste on an iovec entry
1322  for(uint_fast32_t _c=0;_c<argRec.argLen;_c+=1) {
1323  char c = argRec.logArgs.asChars[_c];
1324  if (OME_EXPECT_FALSE(c == '%')) { // escape formatting character ...
1325  *(dest++) = '%'; // ...by adding it twice
1326  }
1327  *(dest++) = c;
1328  }
1329  argCount -= 1; // delete argument
1330  break;
1331  case LOG_ARG_TYPE_FLOAT:
1332  memcpy(dest, "%g", 2);
1333  dest += 2;
1334  break;
1335  case LOG_ARG_TYPE_DOUBLE:
1336  memcpy(dest, "%g", 2);
1337  dest += 2;
1338  break;
1339  // TODO: [u]int_to_ascii() is fast enough that it
1340  // could make sense to convert to a string right here
1341  // but then we lose the binary element if the data was
1342  // assembled using the operator<<().
1343  case LOG_ARG_TYPE_INT32:
1344  memcpy(dest, "%d", 2);
1345  dest += 2;
1346  break;
1347  case LOG_ARG_TYPE_UINT32:
1348  memcpy(dest, "%u", 2);
1349  dest += 2;
1350  break;
1351 
1352  case LOG_ARG_TYPE_INT64:
1353 /* we copy the null to make these even in length, which then
1354  * permits it to be copied via 1 instruction rather than 3.
1355  */
1356  memcpy(dest, "%ld", 4);
1357  dest += 3;
1358  break;
1359  case LOG_ARG_TYPE_UINT64:
1360  memcpy(dest, "%lu", 4);
1361  dest += 3;
1362  break;
1363  case LOG_ARG_TYPE_POSIX_NANOSECONDS: {
1364  memcpy(dest, "%N", 2); // use our special processing format marker
1365  dest += 2;
1366  }
1367  break;
1368  case LOG_ARG_TYPE_FIXED_POINT:
1369  memcpy(dest, "%P", 2); // use our special processing format marker
1370  dest += 2;
1371  break;
1372  default:
1373  std::cerr << "unknown field type: " << argRec.argBaseType << std::endl;
1374  argCount -= 1; // delete it
1375  break;
1376  } // end switch
1377  *dest = '\0';
1378  logLineFormat = generatedFormatLine;
1379  generatedOffset = (uint32_t) (dest - generatedFormatLine);
1380  return (generatedOffset); // return length
1381  } // end generate format string
1382 
1383 
1399  SharedBufferAllocRecord *formatRecordAsText(unsigned int prefixWithFlags,
1400  size_t *returnLen=nullptr, uint32_t singleThreaded=false) OME_ALWAYS_OPTIMIZE("-O3");
1401 
1415  size_t writeAsTextToBuffer(unsigned int prefixWithFlags) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3") {
1416  IO_Processor *ioMgr = logMgr->get_IO_Manager();
1417  // Technically, if we use a special LogMessageRecord associated
1418  // with an IO_Manager lacking an IO_Processor, then we would be
1419  // single-threaded...but we also don't want to perform any
1420  // physical I/O in that scenario....hence we will indicate
1421  // we don't want any processing done.
1422  uint32_t curState = OME_EXPECT_TRUE(ioMgr != nullptr) ? ioMgr->currentThreadState : 0;
1423  uint32_t okToProcess = curState & IO_Processor::PROCESS_DURING_READ;
1424 
1425  size_t result;
1426  SharedBufferAllocRecord *rec = formatRecordAsText(prefixWithFlags, &result, okToProcess);
1427  if (OME_EXPECT_TRUE(rec != nullptr)) {
1428  result = logMgr->writeDataToBuffer(rec);
1429  }
1430  return (result);
1431  }
1432 
1451  SharedBufferAllocRecord *prepareBinaryRecord(unsigned int prefixWithFlags,
1452  size_t *returnLen=nullptr, uint32_t singleThreaded=false);
1453 
1466  size_t writeAsBinaryToBuffer(unsigned int prefixWithFlags) {
1467  IO_Processor *ioMgr = logMgr->get_IO_Manager();
1468  uint32_t curState = OME_EXPECT_TRUE(ioMgr != nullptr) ? ioMgr->currentThreadState : 0;
1469  uint32_t okToProcess = curState & IO_Processor::PROCESS_DURING_READ;
1470 
1471  size_t result;
1472  SharedBufferAllocRecord *rec = prepareBinaryRecord(prefixWithFlags, &result, okToProcess);
1473  if (OME_EXPECT_TRUE(rec != nullptr)) {
1474  result = logMgr->writeDataToBuffer(rec);
1475  }
1476  return (result);
1477  }
1478 
1483  template <typename T> void emitOverflowError(const T &arg) OME_COLD_ROUTINE;
1484 
1485 }; // end class LogMessageRecord
1486 
1487 template <typename T> inline void LogMessageRecord::emitOverflowError(const T &arg) {
1488  argCountExceeded += 1;
1489  std::cerr << "LogMessageRecord overflowEventCount=" << argCountExceeded <<
1490  " maxArgumentTotal=" << LogMessageRecord::LOG_MAX_ARGUMENT_TOTAL <<
1491  " location=\"" << sourceFile << ":" << sourceLine << "\"" <<
1492  " argument=" << arg <<
1493  std::endl;
1494 }
1495 
1496 // logRec and arg are predeclared arguments to function
1497 #define _ADD_NEW_LOG_ARG(typeEnum,member) \
1498  LogMessageRecord::ArgumentRecord &argRec = logRec.argList[logRec.argCount]; \
1499  argRec.logArgs. member = arg; \
1500  argRec.argLen = sizeof(arg); \
1501  argRec.argBaseType = typeEnum; \
1502  logRec.argCount += 1
1503 
1504 #define _ADD_NEW_LOG_ARG_WITH_VALUE_AND_LEN(typeEnum,member,val,len) \
1505  LogMessageRecord::ArgumentRecord &argRec = logRec.argList[logRec.argCount]; \
1506  argRec.logArgs. member = val; \
1507  argRec.argLen = len; \
1508  argRec.argBaseType = typeEnum; \
1509  logRec.argCount += 1
1510 
1511 extern void addLogArg(LogMessageRecord &logRec, const int32_t arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1512 extern void addLogArg(LogMessageRecord &logRec, const uint32_t arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1513 #if (__clang__ != 0)
1514 extern void addLogArg(LogMessageRecord &logRec, const long arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1515 extern void addLogArg(LogMessageRecord &logRec, const unsigned long arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1516 #endif
1517 
1518 extern void addLogArg(LogMessageRecord &logRec, const int64_t arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1519 extern void addLogArg(LogMessageRecord &logRec, const uint64_t arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1520 extern void addLogArg(LogMessageRecord &logRec, const size_t arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1521 extern void addLogArg(LogMessageRecord &logRec, const ssize_t arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1522 extern void addLogArg(LogMessageRecord &logRec, const float arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1523 extern void addLogArg(LogMessageRecord &logRec, const double arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1524 extern void addLogArg(LogMessageRecord &logRec, const char arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1526 extern void addLogArg(LogMessageRecord &logRec, const char *arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1528 extern void addLogArg(LogMessageRecord &logRec, const void *arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1529 extern void addLogArg(LogMessageRecord &logRec, const std::string &arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1530 extern void addLogArg(LogMessageRecord &logRec, uint_fast32_t len, const char *arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1531 extern void addLogArg(LogMessageRecord &logRec, const void *arg, const size_t l) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1532 extern void addLogArg(LogMessageRecord &logRec, const TextBlock_struct &arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1535 
1541 inline void addLogArg(LogMessageRecord &logRec, const int32_t arg)
1542 {
1544 }
1545 
1551 inline void addLogArg(LogMessageRecord &logRec, const uint32_t arg)
1552 {
1554 }
1555 
1556 #if (__clang__ != 0)
1557 
1562 inline void addLogArg(LogMessageRecord &logRec, const long arg)
1563 {
1565 }
1566 
1572 inline void addLogArg(LogMessageRecord &logRec, const unsigned long arg)
1573 {
1575 }
1576 #endif
1577 
1583 inline void addLogArg(LogMessageRecord &logRec, const int64_t arg)
1584 {
1586 }
1587 
1593 inline void addLogArg(LogMessageRecord &logRec, const uint64_t arg)
1594 {
1596 }
1597 
1603 inline void addLogArg(LogMessageRecord &logRec, const float arg)
1604 {
1606 }
1607 
1613 inline void addLogArg(LogMessageRecord &logRec, const double arg)
1614 {
1616 }
1617 
1623 inline void addLogArg(LogMessageRecord &logRec, const char arg)
1624 {
1626 }
1627 
1633 inline void addLogArg(LogMessageRecord &logRec, const POSIXtimeInNanoseconds arg)
1634 {
1636 }
1637 
1647 inline void addLogArg(LogMessageRecord &logRec, const char *arg)
1648 {
1650 }
1651 
1662 inline void addLogArg(LogMessageRecord &logRec, uint_fast32_t len, const char *arg)
1663 {
1665 }
1666 
1676 inline void addLogArg(LogMessageRecord &logRec, const TextBlock_struct &arg)
1677 {
1678  if (arg.bfrLen <= 8) { // copy characters to log argument entry
1679  LogMessageRecord::ArgumentRecord &argRec = logRec.argList[logRec.argCount];
1680  for(uint_fast8_t i=0;i<arg.bfrLen;i+=1) {
1681  argRec.logArgs.asChars[i] = arg.textBfr[i];
1682  }
1683  argRec.argLen = arg.bfrLen;
1685  logRec.argCount += 1;
1686  } else { // point to block
1689  }
1690 }
1691 
1701 inline void addLogArg(LogMessageRecord &logRec, const BinaryBlock_struct &arg)
1702 {
1703  if (arg.bfrLen <= 8) { // copy characters to log argument entry
1704  LogMessageRecord::ArgumentRecord &argRec = logRec.argList[logRec.argCount];
1705  for(uint_fast8_t i=0;i<arg.bfrLen;i+=1) {
1706  argRec.logArgs.bytes[i] = reinterpret_cast<const unsigned char *>(arg.dataBfr)[i];
1707  }
1708  argRec.argLen = arg.bfrLen;
1710  logRec.argCount += 1;
1711  } else {
1712  // NOTE: fragment is used rather than POINTER so that a zero-length block
1713  // is not interpreted as a pointer value.
1715  }
1716 }
1717 
1728 inline void addLogArg(LogMessageRecord &logRec, StringInROM arg)
1729 {
1730 //std::cerr << "Add ROM: " << (char *) arg << std::endl;
1732 }
1733 
1743 inline void addLogArg(LogMessageRecord &logRec, const std::string &arg)
1744 {
1746 }
1747 
1753 inline void addLogArg(LogMessageRecord &logRec, const void *arg)
1754 {
1756 }
1757 
1768 inline void addLogArg(LogMessageRecord &logRec, const void *arg, const size_t l)
1769 {
1771 }
1772 
1773 
1784 inline void addLogArg(LogMessageRecord &logRec, const HexadecimalBlock_struct &arg)
1785 {
1786  // NOTE: fragment is used rather than POINTER so that a zero-length block
1787  // is not interpreted as a pointer value.
1790 }
1791 
1792 #if 0
1793 // which is intended to automatically add constant text strings.
1795 template <unsigned int N> inline void addLogArg(LogMessageRecord &logRec, const char arg[N]) { // this fits the pattern of "text" constants
1796  addLogArg(logRec, (StringInROM) arg);
1797 }
1798 #endif
1799 
1806 #define __EXPLICIT_LOG_MESSAGE_BODY { \
1807  if (OME_EXPECT_FALSE(logRec.argCount >= LogMessageRecord::LOG_MAX_ARGUMENT_TOTAL)) { \
1808  logRec.emitOverflowError(arg); \
1809  return (logRec); \
1810  } \
1811  addLogArg(logRec, arg); \
1812  logRec.generateFormatString(logRec.argCount - 1); \
1813  return (logRec); \
1814 }
1815 
1827 
1829 {
1831 }
1832 
1833 extern LogMessageRecord &operator<<(LogMessageRecord &logRec, const int32_t arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1834 
1835 inline LogMessageRecord &operator<<(LogMessageRecord &logRec, const int32_t arg)
1836 {
1838 }
1839 
1840 extern LogMessageRecord &operator<<(LogMessageRecord &logRec, const uint32_t arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1841 
1842 inline LogMessageRecord &operator<<(LogMessageRecord &logRec, const uint32_t arg)
1843 {
1845 }
1846 
1847 #ifdef __Clang__ /* __SIZEOF_INT__ == __SIZEOF_LONG__ */
1848 // int and long are same size, so add routines to handle long
1849 extern LogMessageRecord &operator<<(LogMessageRecord &logRec, const unsigned long arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1850 
1851 inline LogMessageRecord &operator<<(LogMessageRecord &logRec, const unsigned long arg)
1852 {
1854 }
1855 
1856 extern LogMessageRecord &operator<<(LogMessageRecord &logRec, const long arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1857 
1858 inline LogMessageRecord &operator<<(LogMessageRecord &logRec, const long arg)
1859 {
1861 }
1862 #endif
1863 
1864 extern LogMessageRecord &operator<<(LogMessageRecord &logRec, const int64_t arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1865 
1866 inline LogMessageRecord &operator<<(LogMessageRecord &logRec, const int64_t arg)
1867 {
1869 }
1870 
1871 extern LogMessageRecord &operator<<(LogMessageRecord &logRec, const uint64_t arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1872 
1873 inline LogMessageRecord &operator<<(LogMessageRecord &logRec, const uint64_t arg)
1874 {
1876 }
1877 
1878 #if (__clang__ != 0)
1879 extern LogMessageRecord &operator<<(LogMessageRecord &logRec, const size_t arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1880 
1881 inline LogMessageRecord &operator<<(LogMessageRecord &logRec, const size_t arg)
1882 {
1884 }
1885 
1886 extern LogMessageRecord &operator<<(LogMessageRecord &logRec, const ssize_t arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1887 
1888 inline LogMessageRecord &operator<<(LogMessageRecord &logRec, const ssize_t arg)
1889 {
1891 }
1892 #endif
1893 
1894 extern LogMessageRecord &operator<<(LogMessageRecord &logRec, const float arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1895 
1896 inline LogMessageRecord &operator<<(LogMessageRecord &logRec, const float arg)
1897 {
1899 }
1900 
1901 extern LogMessageRecord &operator<<(LogMessageRecord &logRec, const double arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1902 
1903 inline LogMessageRecord &operator<<(LogMessageRecord &logRec, const double arg)
1904 {
1906 }
1907 
1908 extern LogMessageRecord &operator<<(LogMessageRecord &logRec, const char arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
1909 
1910 inline LogMessageRecord &operator<<(LogMessageRecord &logRec, const char arg)
1911 {
1913 }
1914 
1916 
1918 {
1920 }
1921 
1928 inline std::ostream &operator<<(std::ostream &os, StringInROM arg)
1929 {
1930  os << (const char *) arg;
1931  return (os);
1932 }
1933 
1934 /* Convert TextBlock_struct type back to <tt>const char *</tt>
1935  *
1936  * \param os references the output stream
1937  * \param arg is the text block to be output.
1938  */
1939 inline std::ostream &operator<<(std::ostream &os, const TextBlock_struct &arg)
1940 {
1941  for(uint_fast32_t i=0;i<arg.bfrLen;i+=1) {
1942  os << arg.textBfr[i];
1943  }
1944  return (os);
1945 }
1946 
1947 /* \brief Convert BinaryBlock_struct type back to <tt>const char *</tt>
1948  *
1949  * \param os references the output stream
1950  * \param arg is the binary data to be output.
1951  */
1952 inline std::ostream &operator<<(std::ostream &os, const BinaryBlock_struct &arg)
1953 {
1954  const unsigned char *bfr = static_cast<const unsigned char *>(arg.dataBfr);
1955  for(uint_fast32_t i=0;i<arg.bfrLen;i+=1) {
1956  os << bfr[i];
1957  }
1958  return (os);
1959 }
1960 
1961 /* \brief Convert HexadecimalBlock_struct type back to <tt>const char *</tt>
1962  *
1963  * \param os references the output stream
1964  * \param arg is the data to be output as hexadecimal characters.
1965  */
1966 inline std::ostream &operator<<(std::ostream &os, const HexadecimalBlock_struct &arg)
1967 {
1968  const unsigned char *bfr = static_cast<const unsigned char *>(arg.dataBfr);
1969  if (OME_EXPECT_TRUE(arg.asLowercase)) {
1970  for(uint_fast32_t i=0;i<arg.bfrLen;i+=1) {
1971  os << byteAsLowercaseHexadecimal[bfr[i]][0] <<
1972  byteAsLowercaseHexadecimal[bfr[i]][1];
1973  }
1974  } else {
1975  for(uint_fast32_t i=0;i<arg.bfrLen;i+=1) {
1976  os << byteAsUppercaseHexadecimal[bfr[i]][0] <<
1977  byteAsUppercaseHexadecimal[bfr[i]][1];
1978  }
1979  }
1980  return (os);
1981 }
1982 
1983 /* \brief Convert EscapedTextBlock_struct type back to escaped text
1984  *
1985  * \param os references the output stream
1986  * \param arg is the string to be output.
1987  */
1988 inline std::ostream &operator<<(std::ostream &os, const EscapedTextBlock_struct &arg)
1989 {
1990  /* we don't want any characters > 128 to be treated as
1991  * a negative subscript
1992  */
1993  const unsigned char *bfr = reinterpret_cast<const unsigned char *>(arg.textBfr);
1994  for(uint_fast32_t i=0;i<arg.bfrLen;i+=1) {
1995  unsigned char c = bfr[i];
1996  uint8_t l = arg.replacementsToUse->escapedLen[c];
1997  if (OME_EXPECT_TRUE(l == 0xff)) {
1998  os << arg.textBfr[i];
1999  } else if (l != 0) { // some replacement text
2000  os << arg.replacementsToUse->escapedChar[c];
2001  }
2002  }
2003  return (os);
2004 }
2005 
2006 extern LogMessageRecord &operator<<(LogMessageRecord &logRec, const char *arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
2007 
2008 inline LogMessageRecord &operator<<(LogMessageRecord &logRec, const char *arg)
2009 {
2011 }
2012 
2013 extern LogMessageRecord &operator<<(LogMessageRecord &logRec, const std::string &arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
2014 
2015 inline LogMessageRecord &operator<<(LogMessageRecord &logRec, const std::string &arg)
2016 {
2018 }
2019 
2020 extern LogMessageRecord &operator<<(LogMessageRecord &logRec, const void *arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3");
2021 
2022 inline LogMessageRecord &operator<<(LogMessageRecord &logRec, const void *arg)
2023 {
2025 }
2026 
2028 
2030 {
2032 }
2033 
2035 
2037 {
2039 }
2040 
2042 
2044 {
2046 }
2047 
2049 
2051 {
2052  /* we don't want any characters > 128 to be treated as
2053  * a negative subscript
2054  */
2055  const unsigned char *bfr = reinterpret_cast<const unsigned char *>(arg.textBfr);
2056 
2057  uint_fast32_t startOffset = 0;
2058  for(uint_fast32_t i=0;i<arg.bfrLen;i+=1) {
2059  unsigned char c = bfr[i];
2060  uint8_t l = arg.replacementsToUse->escapedLen[c];
2061  if (OME_EXPECT_TRUE(l != 0xff)) { // some replacement to be done
2062  uint_fast32_t priorBlockLen = i - startOffset;
2063  if (priorBlockLen != 0) { // output data before
2064  BinaryBlock_struct block(arg.textBfr + startOffset, priorBlockLen);
2065  logRec << block;
2066  }
2067  if (l != 0) { // output alternate
2069  logRec << block;
2070  }
2071  startOffset = i + 1;
2072  }
2073  }
2074  uint_fast32_t blockLen = arg.bfrLen - startOffset;
2075  if (blockLen > 0) {
2076  BinaryBlock_struct block(arg.textBfr + startOffset, blockLen);
2077  logRec << block;
2078  }
2079  return (logRec);
2080 }
2081 
2087 #define AS_TEXT_BUFFER(s,...) TextBlock_struct(s,__VA_ARGS__)
2088 
2100 #define AS_ESCAPED_TEXT_BUFFER(...) EscapedTextBlock_struct(__VA_ARGS__)
2101 
2112 #define AS_ESCAPED_TEXT_CHARACTER(...) EscapedTextBlock_struct(__VA_ARGS__)
2113 
2122 #define AS_BINARY_BUFFER(d,l) BinaryBlock_struct(d,l)
2123 
2135 #define AS_HEXADECIMAL_BUFFER(d,...) HexadecimalBlock_struct(d,__VA_ARGS__)
2136 
2137 
2145 public:
2157  AutoRegisterLogLevelName(const char *name, uint32_t mask,
2158  const char *label=nullptr)
2159  {
2160  LogMessageRecord::define_commandline_flag(name, mask, label);
2161  }
2162 
2164 }; // end class AutoRegisterLogLevelName
2165 
2166 #if 1
2167 /* NOTE: this component only works 100% on POSIX systems,
2168  * but can provide viable results on Microsoft Windows using
2169  * the standard handles.
2170  */
2171 
2178 protected:
2183  unsigned char bfrBlock[0x2000];
2184 public:
2185  static int acceptData(SharedBufferAllocRecord *rec, IO_Processor *controller);
2186 
2188  const char *label = "replumb");
2189 
2191 };
2192 
2193 #endif // end ReplumbAndLog
2194 
2195 /* NOTE: "component" must be suitable for a variable name
2196  * and is not a string
2197  */
2198 
2199 // \brief Concatenate two tokens together to create new variable name.
2200 #define _LOGAPI_APPEND_TOKEN(component,suffix) component ## suffix
2201 
2207 #define LOGAPI_APPEND_TOKEN(component,suffix) _LOGAPI_APPEND_TOKEN(component,suffix)
2208 
2214 #define COMPONENT_LOG_MASK(component) LOGAPI_APPEND_TOKEN(component,_logLevelMask)
2215 
2217 #define THIS_COMPONENT_LOG_MASK COMPONENT_LOG_MASK(THIS_COMPONENT)
2218 
2224 #ifndef ISABLE_ALL_LOG_MASK
2225 #define ISABLE_ALL_LOG_MASK 0
2226 #endif
2227 
2250 #define DISABLE_COMPONENT_LOG_MASK(component) LOGAPI_APPEND_TOKEN(ISABLE_, LOGAPI_APPEND_TOKEN(component,_logMask))
2251 
2271 #define COMPONENT_LOG_ENABLED(component, mask) OME_EXPECT( ( ((mask & LOGAPI_APPEND_TOKEN(component,_disableMask)) == 0 ) && (((uint32_t)(COMPONENT_LOG_MASK(component)) & (mask & ~LogMessageRecord::AND_SPECIAL_MASK)) == (mask & ~LogMessageRecord::AND_SPECIAL_MASK)) ), (static_cast<uint_fast32_t>(mask) & static_cast<uint_fast32_t>(LogMessageRecord::LOG_SEVERITY_DEBUG | LogMessageRecord::LOG_SEVERITY_TRACE | LogMessageRecord::LOG_SEVERITY_USER)) )
2272 
2273 
2274 /* \brief Compose symbolic log mask name for a component and level,
2275  * providing one level of macro expansion.
2276  *
2277  * \param component specifies the component name. It must be a legal
2278  * variable name; it is not a string.
2279  * \param level names the log level (e.g., info, error, trace, etc.)
2280  */
2281 #define _COMPONENT_LEVEL(component, level) component ## _ ## level
2282 
2288 #define COMPONENT_LEVEL(component, level) _COMPONENT_LEVEL(component, level)
2289 
2294 #define THIS_COMPONENT_LEVEL(level) COMPONENT_LEVEL(THIS_COMPONENT, level)
2295 
2302 #define ENABLE_COMPONENT_LOG_LEVEL(component, level) COMPONENT_LOG_MASK(component) = (uint32_t) COMPONENT_LOG_MASK(component) | COMPONENT_LEVEL(component,level)
2303 
2310 #define DISABLE_COMPONENT_LOG_LEVEL(component, level) COMPONENT_LOG_MASK(component) = (uint32_t) COMPONENT_LOG_MASK(component) & ~ COMPONENT_LEVEL(component,level)
2311 
2322 #define COMPONENT_USER_LEVEL(component, baseLevel, N) (COMPONENT_LEVEL(component, baseLevel) | (COMPONENT_LEVEL(component, user) * (1 << N)))
2323 
2332 #define THIS_COMPONENT_USER_LEVEL(baseLevel,N) COMPONENT_USER_LEVEL(THIS_COMPONENT, baseLevel, N)
2333 
2346 #define DECLARE_COMPONENT_USER_LOG_MASK(component,name,baseLevel,N) enum { COMPONENT_LEVEL(component, name) = COMPONENT_USER_LEVEL(component,baseLevel,N) }
2347 
2348 /* NOTE: there are two cases to be handled for treating the compile-time
2349  * log-message disable mask: 1) the mask was already -Defined, which means
2350  * it will get expanded to the interesting number or 2) it wasn't, in which
2351  * case the token is left as-is and looks like a identifier name.
2352  * That's a big problem for a macro. We'd like to be able to do:
2353  * #ifndef DISABLE_COMPONENT_LOG_MASK(component)
2354  * #define DISABLE_COMPONENT_LOG_MASK(component) 0
2355  * #endif
2356  * and have the define declare an object token rather than a function macro,
2357  * but that's not how it works.
2358  * This is solved by declaring an identifier almost exactly like the
2359  * macro name that could be defined, but with a 0 appended to it. This has one
2360  * obvious effect: it makes a unique name that won't be altered regardless
2361  * of the definition of the log mask macro. The choice of 0 is crucial, though,
2362  * because we understand the mathemetical property of appending a zero to a
2363  * decimal number: we can simply divide by 10 to obtain the original value.
2364  * So in the case where the log mask is not defined, we emit code like:
2365  * ISABLE_component_logMask0 = 0,
2366  * component_disableMask = ISABLE_component_logMask0 / 10,
2367  * In this case, the prior enum value introduces the identifier we need
2368  * to allow this to compile. If the macro had defined as 1234, we'd instead
2369  * see the last line become:
2370  * component_disableMask = 12340 / 10,
2371  * The compiler does the division at compile time to restore the desired
2372  * value of 1234.
2373  */
2374 
2381 #define _DEFINE_COMPONENT_LOG_MASKS(component) enum { \
2382  component ## _none = 0, \
2383  component ## _trace = LogMessageRecord::LOG_SEVERITY_TRACE, \
2384  component ## _debug = LogMessageRecord::LOG_SEVERITY_DEBUG, \
2385  component ## _info = LogMessageRecord::LOG_SEVERITY_INFO, \
2386  component ## _information = LogMessageRecord::LOG_SEVERITY_INFO, \
2387  component ## _warn = LogMessageRecord::LOG_SEVERITY_WARN, \
2388  component ## _warning = LogMessageRecord::LOG_SEVERITY_WARN, \
2389  component ## _warningAndSyslog = LogMessageRecord::LOG_SEVERITY_WARN | LogMessageRecord::AND_USE_SYSLOG, \
2390  component ## _warningAndStderr = LogMessageRecord::LOG_SEVERITY_WARN | LogMessageRecord::AND_USE_STDERR, \
2391  component ## _warningAndBroadcast = LogMessageRecord::LOG_SEVERITY_WARN | LogMessageRecord::AND_USE_SYSLOG | LogMessageRecord::AND_USE_STDERR, \
2392  component ## _error = LogMessageRecord::LOG_SEVERITY_ERROR, \
2393  component ## _errorAndSyslog = LogMessageRecord::LOG_SEVERITY_ERROR | LogMessageRecord::AND_USE_SYSLOG, \
2394  component ## _errorAndStderr = LogMessageRecord::LOG_SEVERITY_ERROR | LogMessageRecord::AND_USE_STDERR, \
2395  component ## _errorAndBroadcast = LogMessageRecord::LOG_SEVERITY_ERROR | LogMessageRecord::AND_USE_SYSLOG | LogMessageRecord::AND_USE_STDERR, \
2396  component ## _fatal = LogMessageRecord::LOG_SEVERITY_FATAL, \
2397  component ## _fatalAndSyslog = LogMessageRecord::LOG_SEVERITY_FATAL | LogMessageRecord::AND_USE_SYSLOG, \
2398  component ## _fatalAndStderr = LogMessageRecord::LOG_SEVERITY_FATAL | LogMessageRecord::AND_USE_STDERR, \
2399  component ## _fatalAndBroadcast = LogMessageRecord::LOG_SEVERITY_FATAL | LogMessageRecord::AND_USE_SYSLOG | LogMessageRecord::AND_USE_STDERR, \
2400  component ## _user = LogMessageRecord::LOG_SEVERITY_USER, \
2401  component ## _userInfo1 = COMPONENT_USER_LEVEL(component, info, 1), \
2402  component ## _userInfo2 = COMPONENT_USER_LEVEL(component, info, 2), \
2403  component ## _userInfo3 = COMPONENT_USER_LEVEL(component, info, 3), \
2404  component ## _userInfo4 = COMPONENT_USER_LEVEL(component, info, 4), \
2405  component ## _userInfo5 = COMPONENT_USER_LEVEL(component, info, 5), \
2406  component ## _userInfo6 = COMPONENT_USER_LEVEL(component, info, 6), \
2407  component ## _userDebug1 = COMPONENT_USER_LEVEL(component, debug, 1), \
2408  component ## _userDebug2 = COMPONENT_USER_LEVEL(component, debug, 2), \
2409  component ## _userDebug3 = COMPONENT_USER_LEVEL(component, debug, 3), \
2410  component ## _userDebug4 = COMPONENT_USER_LEVEL(component, debug, 4), \
2411  component ## _userDebug5 = COMPONENT_USER_LEVEL(component, debug, 5), \
2412  component ## _userDebug6 = COMPONENT_USER_LEVEL(component, debug, 6), \
2413  component ## _userTrace1 = COMPONENT_USER_LEVEL(component, trace, 1), \
2414  component ## _userTrace2 = COMPONENT_USER_LEVEL(component, trace, 2), \
2415  component ## _userTrace3 = COMPONENT_USER_LEVEL(component, trace, 3), \
2416  component ## _userTrace4 = COMPONENT_USER_LEVEL(component, trace, 4), \
2417  component ## _userTrace5 = COMPONENT_USER_LEVEL(component, trace, 5), \
2418  component ## _userTrace6 = COMPONENT_USER_LEVEL(component, trace, 6), \
2419  component ## _userLevel1 = COMPONENT_USER_LEVEL(component, none, 1), \
2420  component ## _userLevel2 = COMPONENT_USER_LEVEL(component, none, 2), \
2421  component ## _userLevel3 = COMPONENT_USER_LEVEL(component, none, 3), \
2422  component ## _userLevel4 = COMPONENT_USER_LEVEL(component, none, 4), \
2423  component ## _userLevel5 = COMPONENT_USER_LEVEL(component, none, 5), \
2424  component ## _userLevel6 = COMPONENT_USER_LEVEL(component, none, 6), \
2425  component ## _basicLevels = component ## _trace | component ## _debug | \
2426  component ## _info | component ## _warn | component ## _error | \
2427  component ## _fatal, \
2428  component ## _defaultMask = LogMessageRecord::LOG_SEVERITY_INFO | \
2429  LogMessageRecord::LOG_SEVERITY_WARN | \
2430  LogMessageRecord::LOG_SEVERITY_ERROR | \
2431  LogMessageRecord::LOG_SEVERITY_FATAL, \
2432  ISABLE_ ## component ## _logMask0 = 0, \
2433  component ## _disableMask = ( LOGAPI_APPEND_TOKEN(DISABLE_COMPONENT_LOG_MASK(component),0) / 10 ) | ( ISABLE_ALL_LOG_MASK ), \
2434  component ## _all = 0x7fffffff }
2435 
2444 #define DEFINE_COMPONENT_LOG_MASKS(component) _DEFINE_COMPONENT_LOG_MASKS(component)
2445 
2446 
2447 
2458 #define AUTO_REGISTER_USER_LOG_MASK(component,name,label) static AutoRegisterLogLevelName LOGAPI_APPEND_TOKEN(autoRegFlag,LOGAPI_APPEND_TOKEN(component,name))(__LOGAPI_EXPAND_STRING2(name),COMPONENT_LEVEL(component,name),((COMPONENT_LEVEL(component,name) & COMPONENT_LEVEL(component,basicLevels)) ? 0 : label))
2459 
2484 #define DEFINE_COMPONENT_USER_LOG_MASK(component,name,baseLevel,N,label) DECLARE_COMPONENT_USER_LOG_MASK(component,name,baseLevel,N); AUTO_REGISTER_USER_LOG_MASK(component,name,label)
2485 
2492 #define _DECLARE_STANDARD_COMPONENT_VARS(component) \
2493  DEFINE_COMPONENT_LOG_MASKS(component); \
2494  extern SharedMemoryVariableNode component ## _namingNode ; \
2495  extern LogMaskType_t COMPONENT_LOG_MASK(component)
2496 
2503 #define DECLARE_STANDARD_COMPONENT_VARS(component) _DECLARE_STANDARD_COMPONENT_VARS(component)
2504 
2513 #define _DEFINE_STANDARD_COMPONENT_VARS_AND_MASK(component,maskValue) \
2514  SharedMemoryVariableNode component ## _namingNode( #component); \
2515  LogMaskType_t COMPONENT_LOG_MASK(component)( #component "_logMask", & component ## _namingNode, maskValue)
2516 
2527 #define DEFINE_STANDARD_COMPONENT_VARS_AND_MASK(component,maskValue) _DEFINE_STANDARD_COMPONENT_VARS_AND_MASK(component,maskValue)
2528 
2543 #define DEFINE_STANDARD_COMPONENT_VARS_AND_DEFAULT(component,defaultMaskName) \
2544  _DEFINE_STANDARD_COMPONENT_VARS_AND_MASK(component,COMPONENT_LEVEL(component,defaultMaskName))
2545 
2556 #define DEFINE_STANDARD_COMPONENT_VARS(component) DEFINE_STANDARD_COMPONENT_VARS_AND_DEFAULT(component,defaultMask)
2557 
2559 #define DEFINE_STANDARD_VARS_FOR_THIS_COMPONENT() DEFINE_STANDARD_COMPONENT_VARS(THIS_COMPONENT)
2560 
2561 /* Internal macros to expand a macro and convert the contents to a string */
2562 #define __LOGAPI_EXPAND_STRING1(x) #x
2563 #define __LOGAPI_EXPAND_STRING2(x) __LOGAPI_EXPAND_STRING1(x)
2564 
2568 #define THIS_COMPONENT_AS_STRING __LOGAPI_EXPAND_STRING2(THIS_COMPONENT)
2569 
2574 #define AUTO_REGISTER_COMPONENT(componentName) static AutoRegisterLogComponent LOGAPI_APPEND_TOKEN(autoReg_,componentName) (COMPONENT_LOG_MASK(componentName), __LOGAPI_EXPAND_STRING2(componentName), LOGAPI_APPEND_TOKEN(componentName,_defaultMask));
2575 
2580 #define AUTO_REGISTER_THIS_COMPONENT() AUTO_REGISTER_COMPONENT(THIS_COMPONENT);
2581 
2595 #define PROCESS_COMMANDLINE_LOG_FLAGS(argc, argv) LogMessageRecord::process_commandline_log_flags(&default_LogSubsystemInfo, argc, argv, &argc, argv)
2596 
2597 
2598 
2612 #define _INIT_AND_OPEN_STANDARD_LOG(argc,argv,component,newArgc,newArgv) LogManager::initializeLogSubsystem(newArgc,newArgv,argc, argv, #component , & COMPONENT_LOG_MASK(component)); LogManager::newStandardLogFile()
2613 
2614 #ifndef _WIN32
2615 #define _STDIN_FD 0
2616 #define _STDOUT_FD 1
2617 #define _STDERR_FD 2
2618 #define _INVALID_DESCRIPTOR -1
2619 #else
2620 #define _STDIN_FD GetStdHandle(STD_INPUT_HANDLE)
2621 #define _STDOUT_FD GetStdHandle(STD_OUTPUT_HANDLE)
2622 #define _STDERR_FD GetStdHandle(STD_ERROR_HANDLE)
2623 #define _INVALID_DESCRIPTOR INVALID_HANDLE_VALUE
2624 #endif
2625 
2626 #ifndef THIS_COMPONENT_LOG_MANAGER
2627 
2641 #define THIS_COMPONENT_LOG_MANAGER LogManager::DEFAULT_LogManager
2642 #endif
2643 
2644 /* Logic: 1) Create buffer _logBfrN[MAX_LOG_LINE_LENGTH * 8] on the stack,
2645  * 2) Create new LogManager _logMgrN on the stack that uses _logBfrN for
2646  * its workspace. No parentNode for naming is provided and
2647  * _INVALID_DESCRIPTOR is used as a fake descriptor (no I/O will be performed).
2648  * No threading is enabled and an appName of "logstream" is used only for a
2649  * label in a never-should-happen core dump.
2650  * The logLinePrefixMask is forced to 0 to prevent any extra data such as
2651  * date, time, thread id, etc. being placed into the generated output line.
2652  * The \ref LOG_APPEND_BUFFER() macro also uses a mask of 0 when it makes
2653  * the formatRecordAsText() call, so a 0 here is not required.
2654  * 3) Create LogMessageRecord logObjN on the stack (as is always the case)
2655  * that is associated with the _logMgrN LogManager object.
2656  * 4) In order to force initialization of the LogMessageRecord,
2657  * use the << operator to append a null string. Since the null string will
2658  * add no data, it has no effect on the output line that would be generated;
2659  * its only purpose is to ensure that at least some << usage was invoked against
2660  * the logObjN variable before its contents are retrieved using
2661  * \c LOG_APPEND_BUFFER().
2662  */
2674 #define LOG_STREAM_OBJECT(n) \
2675  unsigned char LOGAPI_APPEND_TOKEN(_logBfr,n)[LogManager::MAX_LOG_LINE_LENGTH*8]; \
2676  LogManager LOGAPI_APPEND_TOKEN(_logMgr,n)(nullptr,_INVALID_DESCRIPTOR,false,"logstream",0,LogManager::MAX_LOG_LINE_LENGTH,LOGAPI_APPEND_TOKEN(_logBfr,n),sizeof( LOGAPI_APPEND_TOKEN(_logBfr,n) )); \
2677  LogMessageRecord LOGAPI_APPEND_TOKEN(logObj,n)(& LOGAPI_APPEND_TOKEN(_logMgr,n), 0, __FILE__, __LINE__, sizeof(__FILE__) - 1); LOGAPI_APPEND_TOKEN(logObj,n) << ""
2678 
2679 
2690 #define FORMAT_LOG_BUFFER(_var,src) do { \
2691  SharedBufferAllocRecord *_bRec = src.formatRecordAsText(0); \
2692  _var = (char *) src.getLogManager()->getBufferManager()->blockAddress(_bRec)
2693 
2696 #define RELEASE_LOG_BUFFER(src) src.getLogManager()->getBufferManager()->returnBlock(_bRec); } while (0)
2697 
2710 #define APPEND_LOG_BUFFER(dest,src) do { char *_addr; \
2711  FORMAT_LOG_BUFFER(_addr, src); \
2712  dest << _addr; \
2713  RELEASE_LOG_BUFFER(src); \
2714  } while (0)
2715 
2716 
2730 #define _INIT_WITH_STANDARD_OUT(argc,argv,component,newArgc,newArgv) LogManager::initializeLogSubsystem(newArgc,newArgv,argc, argv, #component , & COMPONENT_LOG_MASK(component)); SharedMemoryVariableNode _logNamingRoot(#component); THIS_COMPONENT_LOG_MANAGER = LogManager::newLogToFileDescriptor(&_logNamingRoot, _STDOUT_FD, default_LogSubsystemInfo.defaultLogPrefix, default_LogSubsystemInfo.useThreads, 0, default_LogSubsystemInfo.maxPendingLogLines * LogManager::MAX_LOG_LINE_LENGTH)
2731 
2736 #define _SET_LOGMGR_FOR(output) SharedMemoryVariableNode _logNamingRoot ## output(#output); LogManager:: output ## _LogManager = LogManager::newLogToFileDescriptor(&_logNamingRoot ## output, _ ## output ## _FD, default_LogSubsystemInfo.defaultLogPrefix, default_LogSubsystemInfo.useThreads, 0, default_LogSubsystemInfo.maxPendingLogLines * LogManager::MAX_LOG_LINE_LENGTH);
2737 
2738 
2752 #define INIT_STANDARD_LOG_FOR_COMPONENT(argc,argv,appName,newArgc,newArgv) _INIT_AND_OPEN_STANDARD_LOG(argc,argv,appName,newArgc,newArgv)
2753 
2766 #define INIT_STANDARD_LOG_FOR_THIS_COMPONENT(argc,argv,newArgc,newArgv) INIT_STANDARD_LOG_FOR_COMPONENT(argc,argv,THIS_COMPONENT,newArgc,newArgv)
2767 
2768 
2777 #define ALWAYS_EMIT_MESSAGE_TO_LOG(logHandle, mask) do { \
2778  LogMessageRecord logObj(logHandle, mask, __FILE__, __LINE__, sizeof(__FILE__) - 1)
2779 
2786 #define ALWAYS_EMIT_MESSAGE(lvl) ALWAYS_EMIT_MESSAGE_TO_LOG(THIS_COMPONENT_LOG_MANAGER, THIS_COMPONENT_LEVEL(lvl))
2787 
2798 #define EMIT_CONDITIONAL_MESSAGE_FOR_COMPONENT_TO_LOG(component,mask,log) if (COMPONENT_LOG_ENABLED(component,mask)) ALWAYS_EMIT_MESSAGE_TO_LOG(log,mask)
2799 
2808 #define EMIT_CONDITIONAL_MESSAGE_FOR_COMPONENT(component,lvl) EMIT_CONDITIONAL_MESSAGE_FOR_COMPONENT_TO_LOG(component,COMPONENT_LEVEL(component,lvl),THIS_COMPONENT_LOG_MANAGER)
2809 
2816 #define EMIT_CONDITIONAL_MESSAGE(lvl) EMIT_CONDITIONAL_MESSAGE_FOR_COMPONENT(THIS_COMPONENT,lvl)
2817 
2822 #define LOG_MESSAGE_FORMAT(s) logObj.setLogFormat(s);
2823 
2828 #define LOG_ARG(arg) addLogArg(logObj, arg);
2829 
2835 #define LOG_BINARY_ARG(arg,len) addLogArg(logObj, arg,len);
2836 
2844 #define LOG_ARG_USING_BUFFER(arg,bfr,bfrLen) addLogArg(logObj, arg, bfr, bfrLen)
2845 
2852 #define AS_PLAIN_TEXT logObj.writeAsTextToBuffer(0); } while (0)
2853 
2858 #define AS_TIMESTAMPED_TEXT logObj.writeAsTextToBuffer(logObj.getLogManager()->getLogPrefixMask()); } while (0)
2859 
2871 #define AS_PREFIXED_TEXT(selectionMask) logObj.writeAsTextToBuffer(selectionMask); } while (0)
2872 
2874 #define AS_BINARY_RECORD logObj.writeAsBinaryToBuffer(logObj.getLogManager()->getLogPrefixMask()); } while (0)
2875 
2877 #define WITH_DATE_TIME_LEVEL logObj.writeAsTextToBuffer( LogMessageRecord::LOG_DATESTAMP | LogMessageRecord::LOG_TIMESTAMP | LogMessageRecord::LOG_ERROR_LEVEL); } while (0)
2878 
2880 #define WITH_TIME_LEVEL logObj.writeAsTextToBuffer(LogMessageRecord::LOG_TIMESTAMP | LogMessageRecord::LOG_ERROR_LEVEL); } while (0)
2881 
2888 #define LOG_WHEN_OSTREAM(stream,lvl) if (COMPONENT_LOG_ENABLED(THIS_COMPONENT,THIS_COMPONENT_LEVEL(lvl))) do { stream
2889 
2891 #define OSTREAM_ENDLINE "\n"; } while (0)
2892 
2903 #define LOG_TO_DESCRIPTOR(output,lvl) EMIT_CONDITIONAL_MESSAGE_FOR_COMPONENT_TO_LOG(THIS_COMPONENT,lvl,output ## _LogManager)
2904 
2905 
2906 /* In the expected case, LOG_USING_OSTREAM will be undefined;
2907  * however, it can be defined to something like std::cout to
2908  * force output to an ostream-like object.
2909  */
2910 #ifndef LOG_USING_OSTREAM
2911 
2917 #define LOG_ALWAYS(lvl) ALWAYS_EMIT_MESSAGE(lvl); logObj
2918 
2925 #define IFLOG_ALWAYS(lvl) if (THIS_COMPONENT_LOG_MANAGER != nullptr) ALWAYS_EMIT_MESSAGE(lvl); logObj
2926 
2933 #define LOG_WHEN(lvl) EMIT_CONDITIONAL_MESSAGE(lvl); logObj
2934 
2941 #define IFLOG_WHEN(lvl) if (THIS_COMPONENT_LOG_MANAGER != nullptr) EMIT_CONDITIONAL_MESSAGE(lvl); logObj
2942 
2948 #define ENDREC "\n"; logObj.writeAsTextToBuffer(logObj.getLogManager()->getLogPrefixMask()); } while (0)
2949 
2953 #define BINARY_ENDREC "\n"; logObj.writeAsBinaryToBuffer(logObj.getLogManager()->getLogPrefixMask()); } while (0)
2954 
2956 #define LOG_ENDLINE ENDREC
2957 
2959 #define BINARY_LOG_ENDLINE BINARY_ENDREC
2960 
2971 #define LOG_COMPONENT_INTO(mgrPtr,component,lvl) EMIT_CONDITIONAL_MESSAGE_FOR_COMPONENT_TO_LOG(component,COMPONENT_LEVEL(component,lvl),mgrPtr); logObj
2972 
2984 #define LOG_COMPONENT_ALWAYS_INTO(mgrPtr,component,lvl) ALWAYS_EMIT_MESSAGE_TO_LOG(mgrPtr,COMPONENT_LEVEL(component,lvl)); logObj
2985 
2992 #define LOG_INTO(mgrPtr,lvl) LOG_COMPONENT_INTO(mgrPtr,THIS_COMPONENT,lvl)
2993 
3000 #define LOG_ALWAYS_INTO(mgrPtr,lvl) LOG_COMPONENT_ALWAYS_INTO(mgrPtr,THIS_COMPONENT,lvl)
3001 
3007 #define LOG_COUT(lvl) LOG_INTO(LogManager::STDOUT_LogManager, lvl)
3008 
3014 #define LOG_CERR(lvl) LOG_INTO(LogManager::STDERR_LogManager, lvl)
3015 
3022 #define LOG_COMPONENT_COUT(component,lvl) LOG_COMPONENT_INTO(LogManager::STDOUT_LogManager,component,lvl)
3023 
3030 #define LOG_COMPONENT_CERR(component,lvl) LOG_COMPONENT_INTO(LogManager::STDERR_LogManager,component,lvl)
3031 
3039 #define LOG_COMPONENT(component,lvl) LOG_COMPONENT_INTO(THIS_COMPONENT_LOG_MANAGER,component,lvl)
3040 
3045 #define LOG_COMPONENT_ALWAYS(component,lvl) LOG_COMPONENT_ALWAYS_INTO(THIS_COMPONENT_LOG_MANAGER,component,lvl)
3046 
3065 #define IFLOG_COMPONENT(component,lvl) if (OME_EXPECT_TRUE(THIS_COMPONENT_LOG_MANAGER != nullptr)) LOG_COMPONENT_INTO(THIS_COMPONENT_LOG_MANAGER,component,lvl)
3066 
3073 #define IFLOG_COMPONENT_ALWAYS(component,lvl) if (OME_EXPECT_TRUE(THIS_COMPONENT_LOG_MANAGER != nullptr)) ALWAYS_EMIT_MESSAGE_TO_LOG(THIS_COMPONENT_LOG_MANAGER,COMPONENT_LEVEL(component,lvl)); logObj
3074 
3075 #else /* LOG_USING_OSTREAM was defined */
3076 
3077 #define LOG_ALWAYS(lvl) do { LOG_USING_OSTREAM
3078 #define IFLOG_ALWAYS(level) if (THIS_COMPONENT_LOG_MANAGER != nullptr) { LOG_USING_OSTREAM
3079 
3080 #define LOG_WHEN(lvl) LOG_WHEN_OSTREAM(LOG_USING_OSTREAM,lvl)
3081 #define IFLOG_WHEN(lvl) if (THIS_COMPONENT_LOG_MANAGER != nullptr) LOG_WHEN_OSTREAM(LOG_USING_OSTREAM,lvl)
3082 
3083 #define LOG_COUT(lvl) LOG_WHEN_OSTREAM(std::cout,lvl)
3084 #define LOG_CERR(lvl) LOG_WHEN_OSTREAM(std::cerr,lvl)
3085 #define LOG_ENDLINE std::endl; } while (0)
3086 #define ENDREC LOG_ENDLINE /* tolerate ENDREC usage */
3087 
3088 #endif // LOG_USING_STREAM not defined (expected case)
3089 
3092 
3097 
3098 
3106 #define SPLIT_ACROSS_LINES(label,...) "BEGIN " << label << "\n"; \
3107  logObj.writeAsTextToBuffer(logObj.getLogManager()->getLogPrefixMask()); \
3108  LogMessageRecord::splitLongLogLine(logObj, __VA_ARGS__); \
3109  logObj << "END " << label
3110 
3111 /* Support native output of sockaddr structures in ASCII readable text
3112  *
3113  * \param os is a reference to the output stream or object
3114  * \param addr is the address to be output as text.
3115  *
3116  * For performance, one would normally NOT use a const reference on these
3117  * simple structures, but because an address is required for the inet_ntop()
3118  * call, a reference is appropriate: we were forced onto the stack already.
3119  */
3120 template <typename STREAM> inline STREAM & operator<<(STREAM& os, const struct in_addr &addr)
3121 {
3122  char buffer[16];
3123  const char *result;
3124 #ifndef _WIN32
3125  // from <arpa/inet.h>
3126  result = inet_ntop(AF_INET, &addr, buffer, sizeof(buffer));
3127 #else
3128  // from Ws2tcpip.h
3129  /* Windows has broken definition that declares second argument as void *
3130  * rather than const void *.
3131  */
3132  result = InetNtop(AF_INET, const_cast<struct in_addr *>(&addr), buffer, sizeof(buffer));
3133 #endif
3134  if (result == nullptr) {
3135  result = "[badipv4]";
3136  }
3137  os << result;
3138  return (os);
3139 }
3140 
3141 template <typename STREAM> inline STREAM & operator<<(STREAM& os, const struct in6_addr &addr)
3142 {
3143  char buffer[64];
3144  const char *result;
3145 #ifndef _WIN32
3146  // from <arpa/inet.h>
3147  result = inet_ntop(AF_INET6, &addr, buffer, sizeof(buffer));
3148 #else
3149  // from Ws2tcpip.h
3150  /* Windows has broken definition that declares second argument as void *
3151  * rather than const void *.
3152  */
3153  result = InetNtop(AF_INET6, const_cast<struct in6_addr *>(&addr), buffer, sizeof(buffer));
3154 #endif
3155  if (result == nullptr) {
3156  result = "[badipv6]";
3157  }
3158  os << result;
3159  return (os);
3160 }
3161 
3162 template <typename STREAM> inline STREAM & operator<<(STREAM& os, const struct sockaddr_in &s)
3163 {
3164  os << "ipv4://";
3165  os << s.sin_addr;
3166  os << ":";
3167  os << ntohs(s.sin_port);
3168  return (os);
3169 }
3170 
3171 template <typename STREAM> inline STREAM & operator<<(STREAM& os, const struct sockaddr_in6 &s)
3172 {
3173  os << "ipv6://";
3174  os << s.sin6_addr;
3175  os << ":";
3176  os << ntohs(s.sin6_port);
3177  return (os);
3178 }
3179 
3180 #ifndef _WIN32
3181 template <typename STREAM> inline STREAM & operator<<(STREAM& os, const struct sockaddr_un &s)
3182 {
3183  os << "file://";
3184  os << s.sun_path;
3185  return (os);
3186 }
3187 #endif
3188 
3189 template <typename STREAM> inline STREAM & operator<<(STREAM& os, const struct sockaddr &s)
3190 {
3191  switch (s.sa_family) {
3192  case AF_INET: {
3193  const struct sockaddr_in *ipv4 = reinterpret_cast<const struct sockaddr_in *>(&s);
3194  os << *ipv4;
3195  }
3196  break;
3197  case AF_INET6: {
3198  const struct sockaddr_in6 *ipv6 = reinterpret_cast<const struct sockaddr_in6 *>(&s);
3199  os << *ipv6;
3200  }
3201  break;
3202 #ifndef _WIN32
3203  case AF_LOCAL: {
3204  const struct sockaddr_un *u = reinterpret_cast<const struct sockaddr_un *>(&s);
3205  os << *u;
3206  }
3207  break;
3208 #endif
3209  default:
3210  os << "[UnknownAF: " << s.sa_family << "]";
3211  break;
3212  }
3213  return (os);
3214 }
3215 
3222 #define _OUTPUT_MEMBER_FIELD(s,f) << " " #f "=" << (s). ## f
3223 
3231 #define _OUTPUT_MEMBER_FIELD_AS_STRING_BLOCK(s,f,l) << " " #f "=\"" << AS_ESCAPED_TEXT_BUFFER((s). ## f, l) << "\""
3232 
3240 #define _OUTPUT_MEMBER_FIELD_AS_STRING(s,f) _OUTPUT_MEMBER_FIELD_AS_STRING_BLOCK(s,f,strlen((s). ## f))
3241 
3244 #endif
3245 /* vim: set expandtab shiftwidth=4 tabstop=4: */
EscapedTextBlock_struct::EscapedTextBlock_struct
EscapedTextBlock_struct(const char justThisChar, const char *quoteTheseChars, const char *escapeUsing=_DEFAULT_REPLACEMENT_CHARACTERS, const char *convertNULL=_DEFAULT_NULL_REPLACEMENT) OME_ALWAYS_INLINE
Escape a single character.
Definition: logging_api.hpp:490
LogMessageRecord::LOG_ARG_TYPE_INT32
@ LOG_ARG_TYPE_INT32
Definition: logging_api.hpp:1096
IO_Processor::PROCESS_THREAD
@ PROCESS_THREAD
Definition: io_processor.hpp:160
_STDERR_FD
#define _STDERR_FD
Platform-independent reference to standard error.
Definition: logging_api.hpp:2617
LogMessageRecord::LOG_argument_union::uc
unsigned char uc
Definition: logging_api.hpp:1080
LogLineBinaryHeader::logPrefixMask
unsigned char logPrefixMask
Definition: logging_api.hpp:167
LogManager::initializeLogSubsystem
static int initializeLogSubsystem(int *newArgc, const char **newArgv, const int argc, const char *argv[], const char *componentName=nullptr, LogMaskType_t *appMaskLocation=nullptr, const uint_fast32_t maxLines=128, const LogMaskPrimitiveType_t logPrefixMask=~0U)
Initialize logging-specific parameters by passing command line arguments.
Definition: logging_api.cpp:700
IO_Processor_Statistics::packetsProcessed
SMV_StandaloneNumeric< uint32_t > packetsProcessed
Definition: io_processor.hpp:127
text2int32
int_fast32_t text2int32(const char *textString, uint_fast8_t text_len) NONNULL_PARAMETERS(1) OME_ALWAYS_OPTIMIZE("-O3")
Convert a sequence of text characters into a 32-bit signed integer as quickly as possible....
Definition: text2int.h:135
BinaryBlock_struct::bfrLen
uint_fast32_t bfrLen
Definition: logging_api.hpp:520
_ADD_NEW_LOG_ARG
#define _ADD_NEW_LOG_ARG(typeEnum, member)
Definition: logging_api.hpp:1497
TimePointCacheForToday
TimePointCache TimePointCacheForToday
Cached TimePoint information representing today.
IO_Processor::statistics
IO_Processor_Statistics * statistics
statistics
Definition: io_processor.hpp:195
l
Ïúíþ ð Ø ˜ ˜ __text __TEXT € __apple_names __DWARF __apple_objc __DWARF __apple_namespac__DWARF H X __apple_types __DWARF l
Definition: tmp3.o.cpp:1
LogManager::filePrefixLen
static uint16_t filePrefixLen[MAX_FILE_PREFIX_ENTRIES]
Definition: logging_api.hpp:582
coalesceCount
SMV_StandaloneNumeric< uint32_t > coalesceCount("coalesceIOVEC")
LogManager::get_IO_Manager
IO_Processor * get_IO_Manager() const OME_ALWAYS_INLINE
Provide access to underlying IO_Processor.
Definition: logging_api.hpp:787
LogLineBinaryValue::LogLineBinaryValue_union::u32
uint32_t u32
Definition: logging_api.hpp:150
IO_Processor
Intermediary I/O processing object for performing multi-threaded receive-and-process operations on a ...
Definition: io_processor.hpp:154
LogSubsystemInfo::maxPendingLogLines
uint32_t maxPendingLogLines
Definition: logging_api.hpp:118
LogLineBinaryValueHeader
Header record for a binary output log line.
Definition: logging_api.hpp:134
LogSubsystemInfo::processID
uint32_t processID
Definition: logging_api.hpp:117
ReplumbAndLog
Intercept output to an existing file descriptor by taking ownership of its destination,...
Definition: logging_api.hpp:2177
LogMessageRecord::LOG_ERROR_LEVEL
@ LOG_ERROR_LEVEL
Include level indicator (INFO, ERROR, etc.)
Definition: logging_api.hpp:1042
LogManager::ioMgr
IO_Processor * ioMgr
Definition: logging_api.hpp:598
LogManager::logPrefixMask
uint_fast32_t logPrefixMask
Definition: logging_api.hpp:601
LogMessageRecord::LOG_ARG_TYPE_POSIX_NANOSECONDS
@ LOG_ARG_TYPE_POSIX_NANOSECONDS
Definition: logging_api.hpp:1110
LogManager::bfrMgr
BufferRegion * bfrMgr
Definition: logging_api.hpp:597
LogManager::closeLog
int closeLog()
Close the open log file.
Definition: logging_api.cpp:1153
LogMessageRecord::LOG_SEVERITY_WARN
@ LOG_SEVERITY_WARN
Definition: logging_api.hpp:1067
LogSubsystemInfo::defaultLogPrefix
uint32_t defaultLogPrefix
Definition: logging_api.hpp:120
s
const char s[]
Definition: t.cpp:4
IO_Processor::currentThreadState
unsigned char currentThreadState
Definition: io_processor.hpp:217
io_processor.hpp
FARGOS I/O Processing classes.
LogManager::stripFilePrefix2
static const char * stripFilePrefix2[MAX_FILE_PREFIX_ENTRIES]
Definition: logging_api.hpp:585
LogManager::MAX_FILE_PREFIX_ENTRIES
@ MAX_FILE_PREFIX_ENTRIES
table size for maximum distinct directory prefixes
Definition: logging_api.hpp:575
LogManager::blockSize
size_t blockSize
Definition: logging_api.hpp:600
BufferRegion::NOT_OWNER
@ NOT_OWNER
indicates region is not owned by this BufferRegion
Definition: circular_bfr.hpp:180
time_point.hpp
FARGOS Time Functions.
LogManager::defaultGetTime
static void defaultGetTime(struct timespec *timestamp, const LogManager *logMgr)
Definition: logging_api.hpp:556
stdout
#define stdout
Definition: tmp.o.cpp:3117
TextBlock_struct::textBfr
const char * textBfr
Definition: logging_api.hpp:218
SharedBufferAllocRecord_32
Allocation record for chains in a 32-bit shared memory buffer.
Definition: circular_bfr.hpp:103
IO_Processor::getExtraData
void * getExtraData() const OME_ALWAYS_INLINE
Retrieve extra information value.
Definition: io_processor.hpp:334
BufferRegion::blockAddress
virtual unsigned char * blockAddress(const SharedBufferAllocRecord *record)
Definition: circular_bfr.hpp:282
LogMessageRecord::LOG_argument_union::i64
int64_t i64
Definition: logging_api.hpp:1083
operator<<
LogMessageRecord & operator<<(LogMessageRecord &logRec, const POSIXtimeInNanoseconds arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3")
Output a POSIXtimeInNanoseconds into a LogMessageRecord.
Definition: logging_api.hpp:1828
LogManager::initializePrefixTable
static void initializePrefixTable()
Initializes the file name prefix tables.
Definition: logging_api.cpp:329
DEBUG
#define DEBUG
Definition: OMEmutex.cpp:19
TimePointOfGranularity::formatIntoString
char * formatIntoString(char *bfr, uint_fast8_t bfrLen, uint_fast8_t *resultLen=nullptr, uint_fast8_t fieldsWanted=OUTPUT_DATE|OUTPUT_TIME, const char *fieldSeparators="/:. ") const
Format into text string.
Definition: time_point.hpp:1273
LogMessageRecord::writeAsTextToBuffer
size_t writeAsTextToBuffer(unsigned int prefixWithFlags) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3")
Format the LogMessageRecord as a text output line (using formatRecordAsText()) and pass the resulting...
Definition: logging_api.hpp:1415
LogMessageRecord::LOG_argument_union::i32
int32_t i32
Definition: logging_api.hpp:1081
LogMessageRecord::LogArgumentLenType_t
uint32_t LogArgumentLenType_t
Typedef for length of field to store argument length.
Definition: logging_api.hpp:1120
_ADD_NEW_LOG_ARG_WITH_VALUE_AND_LEN
#define _ADD_NEW_LOG_ARG_WITH_VALUE_AND_LEN(typeEnum, member, val, len)
Definition: logging_api.hpp:1504
LogManager::stripLeadingDirectories
uint32_t stripLeadingDirectories
Definition: logging_api.hpp:602
LogLineBinaryHeader::importanceLevel
uint32_t importanceLevel
Definition: logging_api.hpp:174
SharedMemoryVariable::SMV_TYPE_INT64
@ SMV_TYPE_INT64
Definition: shared_variable.hpp:49
LogLineBinaryHeader::formatVersion
unsigned char formatVersion
Version identifier for header layout.
Definition: logging_api.hpp:163
EscapedTextBlock_struct::EscapedTextBlock_struct
EscapedTextBlock_struct(const std::string &bfr, const Escaped_Replacement_Characters &useReplacements=defaultEscapePatterns) OME_ALWAYS_INLINE
Escape std::string.
Definition: logging_api.hpp:478
LogMessageRecord::LOG_ARG_TYPE_CHAR
@ LOG_ARG_TYPE_CHAR
Definition: logging_api.hpp:1103
byteAsLowercaseHexadecimal
const char byteAsLowercaseHexadecimal[256][3]
Table of uppercase hexadecimal characters for each byte value.
Definition: text2int.cpp:38
SMV_StandaloneNumeric
Convenience template for creating shared memory variables of one of the supported numeric types....
Definition: shared_variable.hpp:436
LOG_LINE_BINARY_FORMAT_BE
@ LOG_LINE_BINARY_FORMAT_BE
Indicates big-endian, IEEE 754 floating point format.
Definition: logging_api.hpp:195
LogMessageRecord::splitLongLogLine
static void splitLongLogLine(LogMessageRecord &context, const char *line, const char *separators=",;", size_t blockLength=LogManager::MAX_LOG_LINE_LENGTH)
Split the content of a null-terminate string across multiple log lines, breaking the lines at appropr...
Definition: logging_api.cpp:2055
LogManager::getLogPrefixMask
uint_fast32_t getLogPrefixMask() const OME_ALWAYS_INLINE
Get current log prefix mask. It will be a combination of bits composed from LogMessageRecord::LogPref...
Definition: logging_api.hpp:647
StringInROM
const struct StringInROM_struct * StringInROM
Typedef to mark string data in text segment.
Definition: logging_api.hpp:206
LogManager::~LogManager
virtual ~LogManager()
Definition: logging_api.cpp:1116
LogManager::getTimestampRoutine
TimeAcquisitionFP getTimestampRoutine
Definition: logging_api.hpp:605
TextBlock_struct::TextBlock_struct
TextBlock_struct(const char *bfr) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3")
Definition: logging_api.hpp:225
SharedMemoryVariable::SMV_TYPE_DOUBLE
@ SMV_TYPE_DOUBLE
Definition: shared_variable.hpp:52
LogLineBinaryHeader::offsetFirstArg
uint32_t offsetFirstArg
Definition: logging_api.hpp:180
stderr
#define stderr
Definition: tmp.o.cpp:3115
HexadecimalBlock_struct::dataBfr
const void * dataBfr
Definition: logging_api.hpp:534
IO_Processor::bufferAddress
unsigned char * bufferAddress(SharedBufferAllocRecord *rec, size_t *bufferLen=nullptr) const OME_ALWAYS_INLINE
Return physical address of a buffer within the context of the local process' address space.
Definition: io_processor.hpp:275
Escaped_Replacement_Characters::escapedChar
char escapedChar[256][MAX_REPLACEMENT_LENGTH+1]
Definition: logging_api.hpp:275
EscapedTextBlock_struct::EscapedTextBlock_struct
EscapedTextBlock_struct(const char *bfr, const Escaped_Replacement_Characters &useReplacements=defaultEscapePatterns) OME_ALWAYS_INLINE
Escape string, determine string length.
Definition: logging_api.hpp:426
LogMessageRecord::LOG_SEVERITY_DEBUG
@ LOG_SEVERITY_DEBUG
Definition: logging_api.hpp:1065
LogManager::pruneDirectoryPrefix
const TextBlock_struct pruneDirectoryPrefix(const char *fileName, const int_fast32_t fileNameLen)
Return the source file name pruned of any leading directory components as indicated by settings impos...
Definition: logging_api.cpp:1040
LogMessageRecord::LOG_ARG_TYPE_TEXT_FRAGMENT
@ LOG_ARG_TYPE_TEXT_FRAGMENT
Definition: logging_api.hpp:1107
LogMessageRecord::LOG_argument_union
Union to hold arbitrary argument value.
Definition: logging_api.hpp:1077
BufferRegion::OWN_BLOCK
@ OWN_BLOCK
indicates region is owned by the BufferRegion and should be recovered when deleted.
Definition: circular_bfr.hpp:181
LogMessageRecord::getSeverityLabel
static const char * getSeverityLabel(uint_fast32_t level)
Definition: logging_api.cpp:432
TimePointCache
Cache locale-specific time data around a particular point in time.
Definition: time_point.hpp:92
AutoRegisterLogComponent
Convenience mechanism to automatically register a log component.
Definition: logging_api.hpp:1002
ReplumbAndLog::ReplumbAndLog
ReplumbAndLog(OS_HANDLE_TYPE existing_fd, IO_processBlockFP rout=acceptData, const char *label="replumb")
Definition: logging_api.cpp:2160
LogManager::_explicitAlignmentPaddding
uint32_t _explicitAlignmentPaddding
Definition: logging_api.hpp:603
LOG_LINE_BINARY_FORMAT_BE_S360
@ LOG_LINE_BINARY_FORMAT_BE_S360
Indicates big-endian, IBM System/360 hexadecimal floating point.
Definition: logging_api.hpp:197
LogMessageRecord::LOG_SEVERITY_TRACE
@ LOG_SEVERITY_TRACE
Definition: logging_api.hpp:1064
IO_Processor_Statistics::bytesProcessed
SMV_StandaloneNumeric< uint64_t > bytesProcessed
Definition: io_processor.hpp:123
LogManager::DEFAULT_LogManager
static LogManager * DEFAULT_LogManager
Default log manager used, set by newStandardLogFile()
Definition: logging_api.hpp:616
LogMessageRecord::sourceLine
uint32_t sourceLine
Line in source file, usually from LINE
Definition: logging_api.hpp:1129
IO_Processor_Statistics
Holds collected statistics for an IO_Processor object.
Definition: io_processor.hpp:118
EscapedTextBlock_struct::textBfr
const char * textBfr
points at text to be processed
Definition: logging_api.hpp:379
LogSubsystemInfo::defaultLogLevel
uint32_t defaultLogLevel
Definition: logging_api.hpp:119
SharedMemoryVariableNode
Intermediate naming node for supporting variable naming hierarchies.
Definition: shared_variable.hpp:318
IO_Processor_Statistics::bytesRead
SMV_StandaloneNumeric< uint64_t > bytesRead
Definition: io_processor.hpp:122
LogManager::getBufferManager
BufferRegion * getBufferManager() const OME_ALWAYS_INLINE
Provide access to the underlying BufferRegion.
Definition: logging_api.hpp:781
OME_ALWAYS_OPTIMIZE
#define OME_ALWAYS_OPTIMIZE(level)
Mark a function to be compiled with a specific level of optimization.
Definition: compiler_hints.h:406
LogLineBinaryValue::LogLineBinaryValue_union::i64
int64_t i64
Definition: logging_api.hpp:151
LogLineBinaryValue::LogLineBinaryValue_union
Definition: logging_api.hpp:147
LogMessageRecord::setLogFormat
void setLogFormat(const char *f) OME_ALWAYS_INLINE
Set arbitrary log line format text.
Definition: logging_api.hpp:1260
ReplumbAndLog::~ReplumbAndLog
~ReplumbAndLog()
Definition: logging_api.hpp:2190
LogManager::cachedFileNameCount
uint32_t cachedFileNameCount
Definition: logging_api.hpp:604
io
LogMaskType_t COMPONENT_LOG_MASK() io("io_logMask", &DEFAULT_sharedMemoryVariableManager, COMPONENT_LEVEL(io, warn)|COMPONENT_LEVEL(io, error)|COMPONENT_LEVEL(io, fatal))
_INVALID_DESCRIPTOR
#define _INVALID_DESCRIPTOR
Platform-independent reference to invalid descriptor.
Definition: logging_api.hpp:2618
LogManager::setStripLeadingDirectories
void setStripLeadingDirectories(uint_fast32_t dirCount)
Definition: logging_api.hpp:674
IO_Processor::getThreadMode
uint32_t getThreadMode() const OME_ALWAYS_INLINE
Get requested thread modes.
Definition: io_processor.hpp:364
LogMessageRecord::LOG_argument_union::u32
uint32_t u32
Definition: logging_api.hpp:1082
LogLineBinaryHeader::lineNumber
uint32_t lineNumber
Definition: logging_api.hpp:173
LogMessageRecord::define_commandline_flag
static int define_commandline_flag(const char *flagName, LogMaskPrimitiveType_t mask, const char *label=nullptr)
Define a new log level name for the command line parser.
Definition: logging_api.cpp:590
LogMessageRecord::logLineFormat
const char * logLineFormat
Points format line for log line.
Definition: logging_api.hpp:1123
SharedMemoryVariable::SMV_TYPE_STRING
@ SMV_TYPE_STRING
Definition: shared_variable.hpp:56
INVALID_HANDLE_VALUE
#define INVALID_HANDLE_VALUE
Definition: logging_api.cpp:85
buffer
long buffer[MAXDLBUF]
Definition: ethers.c:42
LogMessageRecord::LOG_ARG_TYPE_TEXT
@ LOG_ARG_TYPE_TEXT
Definition: logging_api.hpp:1102
_SET_LOGMGR_FOR
#define _SET_LOGMGR_FOR(output)
Create log manager for STDOUT or STDERR.
Definition: logging_api.hpp:2736
OME_COLD_ROUTINE
#define OME_COLD_ROUTINE
Annotation macro to tell compiler a routine may never be used.
Definition: compiler_hints.h:370
LogManager::logTimePointCache
TimePointCache logTimePointCache
Definition: logging_api.hpp:612
LogMessageRecord::LOG_argument_union::f
float f
Definition: logging_api.hpp:1085
LogManager::LogManager
LogManager(SharedMemoryVariableNode *parentNode, OS_HANDLE_TYPE output_fd, uint_fast8_t useSeparateThread, const char *appName, uint_fast32_t logLinePrefixMask=~0U, uint_fast32_t maxLineSize=(LogManager::MAX_LOG_LINE_LENGTH - sizeof(SharedBufferAllocRecord)), unsigned char *region=nullptr, size_t bytes=(LogManager::MAX_LOG_LINE_LENGTH *64))
Create anonymous buffer.
Definition: logging_api.cpp:958
LogMessageRecord::LOG_FILENAME
@ LOG_FILENAME
Include source filename on logline.
Definition: logging_api.hpp:1040
Escaped_Replacement_Characters::Escaped_Replacement_Characters
Escaped_Replacement_Characters(const char *quoteTheseChars=_DEFAULT_ESCAPED_CHARACTERS, const char *escapeUsing=_DEFAULT_REPLACEMENT_CHARACTERS, const char *convertNULL=_DEFAULT_NULL_REPLACEMENT) OME_ALWAYS_INLINE
Constructor that dynamically prepares content.
Definition: logging_api.hpp:343
LogMessageRecord::LOG_ARG_TYPE_INT64
@ LOG_ARG_TYPE_INT64
Definition: logging_api.hpp:1098
Escaped_Replacement_Characters::MAX_REPLACEMENT_LENGTH
@ MAX_REPLACEMENT_LENGTH
Definition: logging_api.hpp:273
ntohs
#define ntohs(x)
Definition: tmp.o.cpp:3103
logFlagBits
struct BitFlagAndName logFlagBits[MAX_DISTINCT_FLAG_ALIASES]
IO_Processor::ThreadMode
ThreadMode
Mask to select threading modes.
Definition: io_processor.hpp:157
LogMessageRecord::formatRecordAsText
SharedBufferAllocRecord * formatRecordAsText(unsigned int prefixWithFlags, size_t *returnLen=nullptr, uint32_t singleThreaded=false) OME_ALWAYS_OPTIMIZE("-O3")
Format LogMessageRecord into text, prefixing the line with the indicated attributes.
Definition: logging_api.cpp:1288
LogManager::allocateBuffer
SharedBufferAllocRecord * allocateBuffer() OME_ALWAYS_INLINE
Allocate a buffer for a log record.
Definition: logging_api.hpp:847
LogLineBinaryValue::LogLineBinaryValue_union::f
float f
Definition: logging_api.hpp:153
BufferRegion::OwnershipState
OwnershipState
Definition: circular_bfr.hpp:179
stderrName
LogManager realize_STDERR_Manager & stderrName("USE_STDERR_THREAD"), "stderr", ~0U, getEnvironValue("STDERR_MAX_LENGTH", 4608), nullptr, getEnvironValue("STDERR_LINES", 64) *LogManager::MAX_LOG_LINE_LENGTH
LogLineBinaryHeader::threadId
uint64_t threadId
Definition: logging_api.hpp:171
LogManager::copyAndWriteData
ssize_t copyAndWriteData(const void *data, size_t len)
Write block of data to the log buffer.
Definition: logging_api.hpp:916
OME_PREFETCH
#define OME_PREFETCH(addr, rw, locality)
Macro to request prefetch.
Definition: compiler_hints.h:362
ReplumbAndLog::namingNode
SharedMemoryVariableNode namingNode
Definition: logging_api.hpp:2182
IO_Processor::setReadAttempts
void setReadAttempts(uint32_t count) OME_ALWAYS_INLINE
Set read attempts before blocking.
Definition: io_processor.hpp:309
LogManager::STDOUT_LogManager
static LogManager * STDOUT_LogManager
Created automatically.
Definition: logging_api.hpp:617
LogManager::STDERR_LogManager
static LogManager * STDERR_LogManager
Created automatically.
Definition: logging_api.hpp:618
fixedpoint_to_ascii
char * fixedpoint_to_ascii(char *resultBfr, uint_fast8_t bfrLen, int64_t value, uint_fast8_t precision, uint_fast8_t *retStrLen, int_fast8_t outputPrecision)
Format a fixed-point value with indicated decimal places.
Definition: text2int.cpp:2734
AutoRegisterLogComponent::~AutoRegisterLogComponent
~AutoRegisterLogComponent()
Definition: logging_api.hpp:1014
LogSubsystemInfo::useThreads
unsigned char useThreads
Definition: logging_api.hpp:121
LogMaskPrimitiveType_t
uint_fast32_t LogMaskPrimitiveType_t
Definition: logging_api.hpp:105
LogManager::getErrorCondition
const char * getErrorCondition() const OME_ALWAYS_INLINE
Return error condition text detected. This is normally used to obtain an explanation of errors report...
Definition: logging_api.hpp:932
IO_Processor::setThreadMode
int setThreadMode(ThreadMode mode)
Set threading mode.
Definition: io_processor.cpp:564
LogMessageRecord::LOG_BINARY_FORMAT_STRING
@ LOG_BINARY_FORMAT_STRING
For binary output, include format string.
Definition: logging_api.hpp:1043
MAX_SUPPORTED_COMPONENTS
#define MAX_SUPPORTED_COMPONENTS
Definition: logging_api.cpp:167
SharedMemoryVariable::SMV_TYPE_FLOAT
@ SMV_TYPE_FLOAT
Definition: shared_variable.hpp:51
LogMessageRecord::AND_USE_SYSLOG
@ AND_USE_SYSLOG
Definition: logging_api.hpp:1071
LogMessageRecord::argCountExceeded
uint32_t argCountExceeded
Definition: logging_api.hpp:1132
srcID
const char srcID[]
Definition: catSym.c:17
LogMessageRecord::LOG_argument_union::u64
uint64_t u64
Definition: logging_api.hpp:1084
LOGFILE_BFR_MAGIC_NUMBER
#define LOGFILE_BFR_MAGIC_NUMBER
Magic number for shared memory log file buffer.
Definition: logging_api.hpp:103
EscapedTextBlock_struct::EscapedTextBlock_struct
EscapedTextBlock_struct(const std::string &bfr, const char *quoteTheseChars, const char *escapeUsing=_DEFAULT_REPLACEMENT_CHARACTERS, const char *convertNULL=_DEFAULT_NULL_REPLACEMENT) OME_ALWAYS_INLINE
Escape std::string.
Definition: logging_api.hpp:464
waitForBufferAllocRecordToBeReady
void waitForBufferAllocRecordToBeReady(SharedBufferAllocRecord *rec)
Verify record is prepared and, if needed, wait until it is prepared.
Definition: circular_wait.hpp:16
LogMessageRecord::LOG_argument_union::d
double d
Definition: logging_api.hpp:1086
LogLineBinaryValueHeader::offsetNextArg
uint32_t offsetNextArg
offset to the next argument
Definition: logging_api.hpp:138
LogManager::setTimeAcquisitionRoutine
void setTimeAcquisitionRoutine(TimeAcquisitionFP routine)
Set alternate timestamp acquisition routine.
Definition: logging_api.hpp:947
LogLineBinaryValue::LogLineBinaryValue_union::u64
uint64_t u64
Definition: logging_api.hpp:152
LogMessageRecord::ArgumentRecord::argBaseType
LogArgumentType argBaseType
Definition: logging_api.hpp:1137
LogMessageRecord::ArgumentRecord
Definition: logging_api.hpp:1135
ADD_IOV_ELEMENT
#define ADD_IOV_ELEMENT(ptr, len, testCount)
Convenience macro to add element to iovec array.
Definition: logging_api.cpp:1278
LogManager::filePrefix2Len
static uint16_t filePrefix2Len[MAX_FILE_PREFIX_ENTRIES]
Definition: logging_api.hpp:583
LogLineBinaryValue::value
union LogLineBinaryValue::LogLineBinaryValue_union value
LogMessageRecord::getSeverityLabelWithLength
static TextBlock_struct getSeverityLabelWithLength(uint_fast32_t level)
Get the text label for a logging level along with its length.
Definition: logging_api.cpp:403
LogMessageRecord::LOG_argument_union::asUCstring
const unsigned char * asUCstring
Definition: logging_api.hpp:1089
LogManager::bufferAddress
unsigned char * bufferAddress(SharedBufferAllocRecord *rec, size_t *bufferLen=nullptr) const OME_ALWAYS_INLINE
Obtain the physical address and length of a buffer from a SharedBufferAllocRecord,...
Definition: logging_api.hpp:871
IO_Processor::READ_AND_PROCESS_ON_SAME_THREAD
@ READ_AND_PROCESS_ON_SAME_THREAD
a single spawned read thread will do both read-and-processing
Definition: io_processor.hpp:167
IO_Processor::descriptor
OS_HANDLE_TYPE descriptor
Definition: io_processor.hpp:210
TimePointCache::isForDay
bool isForDay(const time_t t) const OME_ALWAYS_INLINE
Definition: time_point.hpp:201
LogLineBinaryHeader
Header for encoded log line template and arguments.
Definition: logging_api.hpp:161
AutoRegisterLogLevelName::AutoRegisterLogLevelName
AutoRegisterLogLevelName(const char *name, uint32_t mask, const char *label=nullptr)
Automatically register a log level name with the command line option parser.
Definition: logging_api.hpp:2157
circular_bfr.hpp
LogMessageRecord::LOG_MAX_ARGUMENT_TOTAL
@ LOG_MAX_ARGUMENT_TOTAL
Maximum number of arguments for an output line.
Definition: logging_api.hpp:1030
LogLineBinaryValue
Represents a single binary log element.
Definition: logging_api.hpp:145
LogMessageRecord::LogLevelSeverityMask
LogLevelSeverityMask
Standard bit flags to define severity level. There is a partial order of implied importance here,...
Definition: logging_api.hpp:1062
mapped_file.h
LogMessageRecord::prepareBinaryRecord
SharedBufferAllocRecord * prepareBinaryRecord(unsigned int prefixWithFlags, size_t *returnLen=nullptr, uint32_t singleThreaded=false)
Assemble LogMesageRecord into a suitable PDU format.
Definition: logging_api.cpp:1869
LogManager::addCachedFileName
void addCachedFileName(const char *fileNameKey, const TextBlock_struct entry)
Definition: logging_api.cpp:1031
LogMessageRecord::LOG_argument_union::ptr
const void * ptr
Definition: logging_api.hpp:1087
LogMessageRecord::LOG_LINE_NUMBER
@ LOG_LINE_NUMBER
Include source line number on logline.
Definition: logging_api.hpp:1041
EscapedTextBlock_struct::EscapedTextBlock_struct
EscapedTextBlock_struct(const char *bfr, const char *quoteTheseChars, const char *escapeUsing=_DEFAULT_REPLACEMENT_CHARACTERS, const char *convertNULL=_DEFAULT_NULL_REPLACEMENT) OME_ALWAYS_INLINE
Escape string, determine string length.
Definition: logging_api.hpp:410
stdoutName
LogManager realize_STDOUT_Manager & stdoutName("USE_STDOUT_THREAD"), "stdout", ~0U, getEnvironValue("STDOUT_MAX_LENGTH", 4608), nullptr, getEnvironValue("STDOUT_LINES", 64) *LogManager::MAX_LOG_LINE_LENGTH
IO_Processor::CONTIGUOUS_FILE_STREAM
@ CONTIGUOUS_FILE_STREAM
contiguous byte stream from file
Definition: io_processor.hpp:185
BinaryBlock_struct::BinaryBlock_struct
BinaryBlock_struct(const void *bfr, uint_fast32_t len) OME_ALWAYS_INLINE
Definition: logging_api.hpp:522
LogManager
Implements multi-threaded, deferred physical I/O log file manager.
Definition: logging_api.hpp:552
POSIXtimeInUnits::convertToNanosecondsSinceEpoch
uint64_t convertToNanosecondsSinceEpoch() const OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3")
Convert a POSIXtimeInUnits to nanoseconds since the POSIX epoch.
Definition: time_point.hpp:471
LogManager::addLogComponent
static uint_fast32_t addLogComponent(const char *componentName, LogMaskType_t *maskLocation, LogMaskPrimitiveType_t initialMask=0)
Add definition of new log component.
Definition: logging_api.cpp:202
LogLineBinaryHeader::argumentCount
uint32_t argumentCount
Definition: logging_api.hpp:176
LogMessageRecord::LOG_ARG_TYPE_FLOAT
@ LOG_ARG_TYPE_FLOAT
Definition: logging_api.hpp:1100
HexadecimalBlock_struct::HexadecimalBlock_struct
HexadecimalBlock_struct(const void *bfr, uint_fast32_t len, bool useLowercase=true) OME_ALWAYS_INLINE
Definition: logging_api.hpp:538
OME_EXPECT_TRUE
#define OME_EXPECT_TRUE(expr)
Annotation macro for conditional expression expected to be true.
Definition: compiler_hints.h:541
StringInROM_struct::stringData
char stringData[1]
Definition: logging_api.hpp:202
IO_Processor::waitForThreadExit
int waitForThreadExit(uint32_t modes)
Wait for threads to terminate.
Definition: io_processor.cpp:728
IO_Processor_Statistics::packetsRead
SMV_StandaloneNumeric< uint32_t > packetsRead
Definition: io_processor.hpp:125
OME_INIT_PRIORITY
#define OME_INIT_PRIORITY(n)
Override initialization priority of a C++ variable.
Definition: compiler_hints.h:372
BufferRegion::allocateBlock
virtual SharedBufferAllocRecord * allocateBlock(size_t len)=0
LogLineBinaryValueHeader::argType
uint32_t argType
type of argument
Definition: logging_api.hpp:136
_DEFAULT_NULL_REPLACEMENT
#define _DEFAULT_NULL_REPLACEMENT
Default replacement for null character by EscapedTextBlock_struct.
Definition: logging_api.hpp:259
TimePointOfGranularity
Representation of localized expanded UNITS-since-epoch.
Definition: time_point.hpp:596
AutoRegisterLogComponent::AutoRegisterLogComponent
AutoRegisterLogComponent(LogMaskType_t &var, const char *name=nullptr, LogMaskPrimitiveType_t defaultMask=0)
Definition: logging_api.hpp:1004
LogLineBinaryValueHeader::_reserved
unsigned char _reserved[3]
Definition: logging_api.hpp:140
IO_Processor::stopThread
int stopThread(uint32_t modes)
Request stop.
Definition: io_processor.cpp:684
LogMessageRecord::sourceFile
const char * sourceFile
Points to source file, usually from FILE
Definition: logging_api.hpp:1124
BufferRegion::returnBlock
virtual void returnBlock(SharedBufferAllocRecord *record)=0
BinaryBlock_struct
Placeholder structure to reference a block of arbitrary data.
Definition: logging_api.hpp:517
POSIXtimeInUnits
Representation of UNITS-since-POSIX-epoch. This is an unambiguous time reference; there is no locale-...
Definition: time_point.hpp:313
LogMessageRecord::LogMessageRecord
LogMessageRecord(LogManager *mgr, uint32_t importanceFlags, const char *atFileName, uint32_t atLineNumber, int_fast32_t fileNameLen=-1) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3")
Definition: logging_api.hpp:1210
LogManager::newLogToFileDescriptor
static LogManager * newLogToFileDescriptor(SharedMemoryVariableNode *parentNode, OS_HANDLE_TYPE fd, LogMaskPrimitiveType_t logPrefixMask, uint_fast8_t useSeparateThreads, unsigned char *region, size_t bytes)
Definition: logging_api.cpp:842
LogMessageRecord::LogPrefixMask
LogPrefixMask
Log line prefix attributes.
Definition: logging_api.hpp:1036
IO_Processor::PROCESS_DURING_READ
@ PROCESS_DURING_READ
Processing will be performed by the read thread.
Definition: io_processor.hpp:162
LogMessageRecord::sourceFileNameLen
uint32_t sourceFileNameLen
Length of sourceFile path.
Definition: logging_api.hpp:1127
text2int.h
Extreme-performance text/number conversion routines.
ReplumbAndLog::logMgr
LogManager * logMgr
Definition: logging_api.hpp:2181
EscapedTextBlock_struct::EscapedTextBlock_struct
EscapedTextBlock_struct(const char *bfr, uint_fast32_t len, const Escaped_Replacement_Characters &useReplacements=defaultEscapePatterns) OME_ALWAYS_INLINE
Escape string of known length with precomputed escapes.
Definition: logging_api.hpp:452
LogLineBinaryHeader::nanosecondTimestamp
uint64_t nanosecondTimestamp
Definition: logging_api.hpp:170
HexadecimalBlock_struct::bfrLen
uint_fast32_t bfrLen
Definition: logging_api.hpp:535
LogLineBinaryValueHeader::argLength
uint32_t argLength
actual length of argument
Definition: logging_api.hpp:137
NULL
#define NULL
Definition: tmp.o.cpp:327
LogMessageRecord::LOG_argument_union::asCstring
const char * asCstring
Definition: logging_api.hpp:1088
EscapedTextBlock_struct::EscapedTextBlock_struct
EscapedTextBlock_struct(const char justThisChar, const Escaped_Replacement_Characters &useReplacements=defaultEscapePatterns) OME_ALWAYS_INLINE
Definition: logging_api.hpp:502
LogLineBinaryValueHeader::headerLen
unsigned char headerLen
length of this header structure
Definition: logging_api.hpp:139
app
LogMaskType_t COMPONENT_LOG_MASK() app("app_logMask", &DEFAULT_sharedMemoryVariableManager, COMPONENT_LEVEL(app, defaultMask))
IO_Processor::submitOrProcessBlock
int submitOrProcessBlock(SharedBufferAllocRecord *rec)
Submission routine that will either directly invoke the processing routine or notify the processing t...
Definition: io_processor.cpp:144
EscapedTextBlock_struct::dynamicReplacements
Escaped_Replacement_Characters dynamicReplacements
storage for dynamically assigned replacements
Definition: logging_api.hpp:383
LogLineBinaryValue::LogLineBinaryValue_union::asChars
char asChars[8]
Definition: logging_api.hpp:148
LogManager::commitLogRecord
static int commitLogRecord(SharedBufferAllocRecord *rec, IO_Processor *controller)
IO_processor-compatible process routine used to write buffered data to an open file.
Definition: logging_api.cpp:1173
HexadecimalBlock_struct::asLowercase
bool asLowercase
Definition: logging_api.hpp:536
LogLineBinaryHeader::offsetFormatString
uint32_t offsetFormatString
Definition: logging_api.hpp:179
float_to_ascii
char * float_to_ascii(char *resultBfr, uint_fast8_t bfrLen, double value, uint_fast8_t *retStrLen, int_fast8_t outputPrecision, bool roundValue)
Format a double-precision value with indicated decimal places.
Definition: text2int.cpp:2808
LogMessageRecord::LOG_SEVERITY_ERROR
@ LOG_SEVERITY_ERROR
Definition: logging_api.hpp:1068
LogMessageRecord
Log message record used to remember output format and argument values, potentially deferring formatti...
Definition: logging_api.hpp:1022
EscapedTextBlock_struct::singleOutputChar
char singleOutputChar
storage for single character
Definition: logging_api.hpp:381
TextBlock_struct::TextBlock_struct
TextBlock_struct(const char *bfr, uint_fast32_t len, bool clipAtNull=false) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3")
Definition: logging_api.hpp:241
COMPONENT_LOG_MASK
#define COMPONENT_LOG_MASK(component)
Construct variable name for a component's active log mask.
Definition: logging_api.hpp:2214
LogManager::logFileName
char logFileName[256]
Definition: logging_api.hpp:614
EscapedTextBlock_struct::bfrLen
uint_fast32_t bfrLen
specifies length of text string
Definition: logging_api.hpp:380
LogManager::errorCondition
const char * errorCondition
Definition: logging_api.hpp:599
LogManager::FileNameCacheEntry::fileName
const char * fileName
Definition: logging_api.hpp:563
BinaryBlock_struct::dataBfr
const void * dataBfr
Definition: logging_api.hpp:519
LogMessageRecord::LOG_ARG_TYPE_BINARY
@ LOG_ARG_TYPE_BINARY
Definition: logging_api.hpp:1104
LogMessageRecord::timestamp
struct timespec timestamp
Timestamp of log event creation.
Definition: logging_api.hpp:1125
SharedMemoryVariable::SMV_TYPE_INT32
@ SMV_TYPE_INT32
Definition: shared_variable.hpp:47
__cplusplus
#define __cplusplus
Definition: tmp.o.cpp:2998
HexadecimalBlock_struct
Placeholder structure to reference a block of arbitrary data to be output in hexadecimal.
Definition: logging_api.hpp:532
int_to_ascii
char * int_to_ascii(uint32_t resultBfr[], uint_fast8_t bfrLen, int64_t value, uint_fast8_t *retStrLen)
Identical to uint_to_ascii(), except that negative values are accepted.
Definition: text2int.cpp:2699
LogManager::setErrorCondition
void setErrorCondition(const char *messageText) OME_ALWAYS_INLINE
Set error condition text.
Definition: logging_api.hpp:938
LogManager::returnBuffer
void returnBuffer(SharedBufferAllocRecord *rec) OME_ALWAYS_INLINE
Return a buffer previously allocated by allocateBuffer().
Definition: logging_api.hpp:857
IO_Processor::NONE
@ NONE
No threads will be spawned.
Definition: io_processor.hpp:158
LogLineBinaryHeader::_reserved
unsigned char _reserved[1]
Definition: logging_api.hpp:168
Escaped_Replacement_Characters::initEscapes
void initEscapes(const char *quoteTheseChars, const char *escapeUsing, const char *convertNULL) OME_ALWAYS_INLINE
Initialize escape table.
Definition: logging_api.hpp:289
LogMessageRecord::LOG_ARG_TYPE_UINT32
@ LOG_ARG_TYPE_UINT32
Definition: logging_api.hpp:1097
shared_variable.hpp
FARGOS Shared Memory Variable routines.
LogMessageRecord::MIN_IOV_UNIT_LEN
@ MIN_IOV_UNIT_LEN
Minimum amount of string bytes worth an iovec entry.
Definition: logging_api.hpp:1032
StringInROM_struct
Structure defined to generate unique type name.
Definition: logging_api.hpp:201
OME_USED
const char srcID[] OME_USED
Definition: tick_time.cpp:24
LogManager::argTimeCacheTable
TimePointCacheTable argTimeCacheTable
Definition: logging_api.hpp:613
flags
int flags
Definition: ethers.c:41
LogManager::setLogPrefixMask
uint_fast32_t setLogPrefixMask(uint_fast32_t newMask) OME_ALWAYS_INLINE
Set the log prefix mask. The new mask is defined as a combination of bits created by OR'ing together ...
Definition: logging_api.hpp:663
LogMessageRecord::LOG_THREAD_ID
@ LOG_THREAD_ID
Include thread id on logline.
Definition: logging_api.hpp:1039
Escaped_Replacement_Characters
Structure to hold table of characters that should be replaced or deleted.
Definition: logging_api.hpp:271
LogMessageRecord::AND_SPECIAL_MASK
@ AND_SPECIAL_MASK
Definition: logging_api.hpp:1073
ReplumbAndLog::bfrBlock
unsigned char bfrBlock[0x2000]
Definition: logging_api.hpp:2183
TimePointCacheTable::getCacheEntry
const TimePointCache & getCacheEntry(time_t t)
Returns a TimePointCache entry for the day indicated by the number of seconds since the POSIX epoch.
Definition: time_point.hpp:292
LogManager::fileNameReplacementCache
FileNameCacheEntry fileNameReplacementCache[FILENAME_CACHE_SIZE]
Definition: logging_api.hpp:606
LogMessageRecord::LOG_TIMESTAMP
@ LOG_TIMESTAMP
Include time on logline.
Definition: logging_api.hpp:1038
interpolated_clock_gettime
int interpolated_clock_gettime(struct timespec *result, bool force)
Get time with nanosecond precision using interpolation of elapsed CPU ticks.
Definition: tick_time.cpp:315
ReplumbAndLog::output_fd
OS_HANDLE_TYPE output_fd
Definition: logging_api.hpp:2180
LogMessageRecord::LOG_SEVERITY_FATAL
@ LOG_SEVERITY_FATAL
Definition: logging_api.hpp:1069
LogManager::newLogFileForComponent
static LogManager * newLogFileForComponent(SharedMemoryVariableNode *parentNode, const char *app, uint_fast32_t filenameCreateFlags, LogMaskPrimitiveType_t logPrefixMask, uint_fast8_t enableMap, uint_fast8_t useSeparateThreads, size_t desiredRegionSize=0, size_t reserveAtEnd=0, const char *inDir=getenv(DEFAULT_LOG_DIRECTORY_ENVIRONMENT_VARIABLE))
Create a new file and LogManager for a component. If desired, also create an auxilary backing file fo...
Definition: logging_api.cpp:856
EscapedTextBlock_struct
Placeholder structure to reference a text fragment that will have selected characters transformed or ...
Definition: logging_api.hpp:368
LogManager::FileNameCacheEntry
Class to maintain fileName->shortened replacement record.
Definition: logging_api.hpp:561
LogMessageRecord::emitOverflowError
void emitOverflowError(const T &arg) OME_COLD_ROUTINE
Called when too many arguments are output.
Definition: logging_api.hpp:1487
LogMessageRecord::ArgumentRecord::logArgs
LOG_argument_union logArgs
Definition: logging_api.hpp:1136
atomic_values.h
Atomic operations.
__EXPLICIT_LOG_MESSAGE_BODY
#define __EXPLICIT_LOG_MESSAGE_BODY
Allow message to be built up using the << operator.
Definition: logging_api.hpp:1806
TextBlock_struct::bfrLen
uint_fast32_t bfrLen
Definition: logging_api.hpp:219
LogManager::getTimestamp
void getTimestamp(struct timespec *timestamp) const OME_ALWAYS_INLINE
Return the current time using the timestamp acquisition routine associated with the log.
Definition: logging_api.hpp:967
LogManager::getTimeAcquisitionRoutine
TimeAcquisitionFP getTimeAcquisitionRoutine() const OME_ALWAYS_INLINE
Return pointer to the time acquistion routine associated with the log.
Definition: logging_api.hpp:958
CircularBufferManager
Impose a circular buffer on a BufferRegion.
Definition: circular_bfr.hpp:330
addLogArg
void addLogArg(LogMessageRecord &logRec, const int32_t arg) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3")
Add log argument of indicated type.
Definition: logging_api.hpp:1541
errno
int errno
Definition: ethers.c:41
LogSubsystemInfo::enableMap
unsigned char enableMap
Definition: logging_api.hpp:122
LOG_ERR
#define LOG_ERR
Definition: getether.c:23
LogMessageRecord::writeAsBinaryToBuffer
size_t writeAsBinaryToBuffer(unsigned int prefixWithFlags)
Format the LogMessageRecord as a binary record (using prepareBinaryRecord()) and pass the resulting b...
Definition: logging_api.hpp:1466
compiler_hints.h
Compiler-specific macros to provide performance-related hints.
LogMessageRecord::generateFormatString
int generateFormatString(unsigned int fieldNum) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3")
Append appropriate format parameters for previously added argument.
Definition: logging_api.hpp:1273
OME_EXPECT_FALSE
#define OME_EXPECT_FALSE(expr)
Annotation macro for conditional expression expected to be false.
Definition: compiler_hints.h:540
LogManager::newStandardLogFile
static LogManager * newStandardLogFile(const char *namedComponent=nullptr, LogMaskPrimitiveType_t filenameCreateFlags=~0U, SharedMemoryVariableNode *parentNode=nullptr)
High-level routine to create a standard log file associated with a component.
Definition: logging_api.cpp:935
LogMessageRecord::LOG_SEVERITY_USER
@ LOG_SEVERITY_USER
Definition: logging_api.hpp:1070
SharedBufferAllocRecord_32::usedLen
uint32_t usedLen
Definition: circular_bfr.hpp:107
Escaped_Replacement_Characters::escapedLen
int8_t escapedLen[256]
Definition: logging_api.hpp:274
OME_ALWAYS_INLINE
#define OME_ALWAYS_INLINE
Tell the compiler to alway inline a function, regardless of optimization level.
Definition: compiler_hints.h:364
LogMaskType_t
SMV_StandaloneNumeric< LogMaskPrimitiveType_t > LogMaskType_t
Definition: logging_api.hpp:106
LogLineBinaryValue::LogLineBinaryValue_union::d
double d
Definition: logging_api.hpp:154
SharedBufferAllocRecord_32::blockLen
uint32_t blockLen
Definition: circular_bfr.hpp:106
_DEFAULT_REPLACEMENT_CHARACTERS
#define _DEFAULT_REPLACEMENT_CHARACTERS
Default replacement characters for EscapedTextBlock_struct.
Definition: logging_api.hpp:257
SharedMemoryVariable::SMV_TYPE_UINT32
@ SMV_TYPE_UINT32
Definition: shared_variable.hpp:48
_STDOUT_FD
#define _STDOUT_FD
Platform-independent reference to standard out.
Definition: logging_api.hpp:2616
LogSubsystemInfo
Descriptive meta-data for log file-related information.
Definition: logging_api.hpp:110
LogLineBinaryValue::LogLineBinaryValue_union::i32
int32_t i32
Definition: logging_api.hpp:149
SharedMemoryVariable::SMV_TYPE_TINY_BINARY_STRING
@ SMV_TYPE_TINY_BINARY_STRING
Definition: shared_variable.hpp:55
LogMessageRecord::LOG_argument_union::bytes
unsigned char bytes[sizeof(char *)]
Definition: logging_api.hpp:1079
IO_Processor::waitForThreadStart
int waitForThreadStart(uint32_t mode)
Wait for threads to start.
Definition: io_processor.cpp:712
LogManager::TimeAcquisitionFP
void(* TimeAcquisitionFP)(struct timespec *, const LogManager *)
Definition: logging_api.hpp:554
MAX_ELEMENT_TOTAL
#define MAX_ELEMENT_TOTAL
Maximum possible iovec elements, usually leading text and the argument data.
Definition: logging_api.cpp:1268
IO_Processor::processBlockRoutine
IO_processBlockFP processBlockRoutine
Definition: io_processor.hpp:199
LogLineBinaryValue::hdr
struct LogLineBinaryValueHeader hdr
Definition: logging_api.hpp:146
BufferRegion::setOwnership
void setOwnership(OwnershipState newOwnership)
Change administrative ownership of region.
Definition: circular_bfr.hpp:232
LogMessageRecord::logMgr
LogManager * logMgr
Points to LogManager used for output.
Definition: logging_api.hpp:1122
makeQualifiedFileName
uint_fast32_t makeQualifiedFileName(char *fileName, uint_fast32_t fileNameLen, const char *componentName, const char *suffix, const char *dirName, uint_fast32_t flags)
Create a filename and optionally qualify with the current date and process Id.
Definition: mapped_file.cpp:98
LogSubsystemInfo::programName
const char * programName
Definition: logging_api.hpp:116
ReplumbAndLog::acceptData
static int acceptData(SharedBufferAllocRecord *rec, IO_Processor *controller)
Definition: logging_api.cpp:2123
LogMessageRecord::LOG_DATESTAMP
@ LOG_DATESTAMP
Include date on logline.
Definition: logging_api.hpp:1037
LogMessageRecord::LOG_ARG_TYPE_HEX_FRAGMENT_UPPER
@ LOG_ARG_TYPE_HEX_FRAGMENT_UPPER
Definition: logging_api.hpp:1109
LogMessageRecord::argCount
uint32_t argCount
Number of arguments for log line.
Definition: logging_api.hpp:1128
LogMessageRecord::LOG_argument_union::asChars
char asChars[sizeof(char *)]
Definition: logging_api.hpp:1078
LogLineBinaryHeader::offsetFileName
uint32_t offsetFileName
Definition: logging_api.hpp:177
Escaped_Replacement_Characters::Escaped_Replacement_Characters
Escaped_Replacement_Characters(bool doNothing)
Constructor that does no preparation.
Definition: logging_api.hpp:333
LogManager::writeDataToBuffer
ssize_t writeDataToBuffer(SharedBufferAllocRecord *rec)
Low-level routine to add a record to log buffer.
Definition: logging_api.cpp:1128
ReplumbAndLog::source_fd
OS_HANDLE_TYPE source_fd
Definition: logging_api.hpp:2179
LogManager::FILENAME_CACHE_SIZE
@ FILENAME_CACHE_SIZE
max entries in prune filename cache
Definition: logging_api.hpp:577
SharedBufferAllocRecord
SharedBufferAllocRecord_32 SharedBufferAllocRecord
Default SharedBufferAllocRecord.
Definition: circular_bfr.hpp:133
OS_HANDLE_TYPE
#define OS_HANDLE_TYPE
Definition: io_processor.hpp:48
LogManager::setSourceForCustomLogTime
static void setSourceForCustomLogTime(POSIXtimeInNanoseconds *timeSource)
Convenience routine to set location of a custom time value for log lines.
Definition: logging_api.cpp:189
LogMessageRecord::LOG_ARG_TYPE_HEX_FRAGMENT
@ LOG_ARG_TYPE_HEX_FRAGMENT
Definition: logging_api.hpp:1108
byteAsUppercaseHexadecimal
const char byteAsUppercaseHexadecimal[256][3]
Table of uppercase hexadecimal characters for each byte value.
Definition: text2int.cpp:78
LogLineBinaryHeader::logLineLength
uint32_t logLineLength
Definition: logging_api.hpp:169
LogMessageRecord::ArgumentRecord::argLen
LogArgumentLenType_t argLen
Definition: logging_api.hpp:1138
BufferRegion
Interface to a buffer region. This is an abstract class.
Definition: circular_bfr.hpp:177
LogManager::copyAndWriteDataToBuffer
ssize_t copyAndWriteDataToBuffer(SharedBufferAllocRecord *rec, const void *data, size_t len)
Low-level routine to copy data and add a record to log buffer.
Definition: logging_api.cpp:1138
LogManager::FileNameCacheEntry::replacementText
TextBlock_struct replacementText
Definition: logging_api.hpp:564
LogMessageRecord::LOG_SEVERITY_INFO
@ LOG_SEVERITY_INFO
Definition: logging_api.hpp:1066
LogMessageRecord::LOG_ARG_TYPE_POINTER
@ LOG_ARG_TYPE_POINTER
Definition: logging_api.hpp:1105
LogMessageRecord::~LogMessageRecord
~LogMessageRecord()
Definition: logging_api.hpp:1242
uint_to_ascii
char * uint_to_ascii(uint32_t resultBfr[], uint_fast8_t bfrLen, uint64_t value, uint_fast8_t *retStrLen)
Quickly convert a binary integer into ASCII decimal text.
Definition: text2int.cpp:2628
LogMessageRecord::argList
struct LogMessageRecord::ArgumentRecord argList[LOG_MAX_ARGUMENT_TOTAL]
LogMessageRecord::LOG_ARG_TYPE_DOUBLE
@ LOG_ARG_TYPE_DOUBLE
Definition: logging_api.hpp:1101
LogMessageRecord::generatedOffset
uint32_t generatedOffset
End of log line generated via << operator.
Definition: logging_api.hpp:1131
zeroFileContents
size_t zeroFileContents(int descriptor, size_t fileLength)
Write out zero-filled blocks to a file.
Definition: mapped_file.cpp:178
DEFAULT_LOG_DIRECTORY_ENVIRONMENT_VARIABLE
#define DEFAULT_LOG_DIRECTORY_ENVIRONMENT_VARIABLE
Definition: logging_api.hpp:100
SharedMemoryVariable::SMV_TYPE_UINT64
@ SMV_TYPE_UINT64
Definition: shared_variable.hpp:50
EscapedTextBlock_struct::EscapedTextBlock_struct
EscapedTextBlock_struct(const char *bfr, uint_fast32_t len, const char *quoteTheseChars, const char *escapeUsing=_DEFAULT_REPLACEMENT_CHARACTERS, const char *convertNULL=_DEFAULT_NULL_REPLACEMENT) OME_ALWAYS_INLINE
Escape string of known length.
Definition: logging_api.hpp:438
AutoRegisterLogLevelName::~AutoRegisterLogLevelName
~AutoRegisterLogLevelName()
Definition: logging_api.hpp:2163
LOG_LINE_BINARY_FORMAT_VER1
@ LOG_LINE_BINARY_FORMAT_VER1
Denotes version of 1 of the header format.
Definition: logging_api.hpp:191
AutoRegisterLogLevelName
Convenience mechanism to automatically register a log level command line flag definition.
Definition: logging_api.hpp:2144
LogLineBinaryHeader::byteOrder
unsigned char byteOrder
Definition: logging_api.hpp:166
MAX_DISTINCT_FLAG_ALIASES
#define MAX_DISTINCT_FLAG_ALIASES
Definition: logging_api.cpp:268
LogMessageRecord::process_commandline_log_flags
static int process_commandline_log_flags(LogSubsystemInfo *info, int argc, const char *argv[], int *newArgc, const char **newArgv)
Process the standard argument list provided to an application and strip out the logging-related optio...
Definition: logging_api.cpp:637
LogManager::killProcessingThread
void killProcessingThread()
Definition: logging_api.hpp:626
_DEFAULT_ESCAPED_CHARACTERS
#define _DEFAULT_ESCAPED_CHARACTERS
Default set of characters to be escaped by EscapedTextBlock_struct.
Definition: logging_api.hpp:255
LogManager::returnCustomLogTime
static void returnCustomLogTime(struct timespec *timestamp, const LogManager *logMgr)
Convenience routine to retrieve a custom timestamp for log lines.
Definition: logging_api.cpp:194
IOV_MAX
#define IOV_MAX
Definition: tmp.o.cpp:268
LogMessageRecord::LOG_ARG_TYPE_FIXED_POINT
@ LOG_ARG_TYPE_FIXED_POINT
Definition: logging_api.hpp:1111
LogMessageRecord::LOG_ARG_TYPE_ROM_TEXT
@ LOG_ARG_TYPE_ROM_TEXT
Definition: logging_api.hpp:1106
LogMessageRecord::LogArgumentType
LogArgumentType
Argument type indicators, reuses those from the SharedMemoryVariables.
Definition: logging_api.hpp:1095
LogMessageRecord::getLogManager
LogManager * getLogManager() const OME_ALWAYS_INLINE
Definition: logging_api.hpp:1244
SharedMemoryVariable::SMV_TYPE_TINY_STRING
@ SMV_TYPE_TINY_STRING
Definition: shared_variable.hpp:54
TextBlock_struct
Placeholder structure to reference a text fragment.
Definition: logging_api.hpp:216
EscapedTextBlock_struct::defaultEscapePatterns
static Escaped_Replacement_Characters defaultEscapePatterns
Pre-generated default escape patterns.
Definition: logging_api.hpp:371
LogMessageRecord::importanceLevel
uint32_t importanceLevel
Value from LogLevelSeverityMask enum.
Definition: logging_api.hpp:1130
EscapedTextBlock_struct::replacementsToUse
const Escaped_Replacement_Characters * replacementsToUse
effective replacement characters
Definition: logging_api.hpp:382
TimePointCacheTable
Convenience class to maintain a table of TimePointCache objects.
Definition: time_point.hpp:269
LogLineBinaryValue::LogLineBinaryValue_union::bytes
unsigned char bytes[8]
Definition: logging_api.hpp:155
fd
int fd
Definition: ethers.c:41
LogMessageRecord::LOG_ARG_TYPE_UINT64
@ LOG_ARG_TYPE_UINT64
Definition: logging_api.hpp:1099
LogManager::findCachedFileName
FileNameCacheEntry findCachedFileName(const char *fileName) const
Definition: logging_api.cpp:1018
DEFINE_COMPONENT_LOG_MASKS
#define DEFINE_COMPONENT_LOG_MASKS(component)
Define default symbolic log mask names for a component.
Definition: logging_api.hpp:2444
LogManager::FileNameCacheEntry::FileNameCacheEntry
FileNameCacheEntry()
Null constructor for cache entry.
Definition: logging_api.hpp:567
LOG_LINE_BINARY_FORMAT_LE
@ LOG_LINE_BINARY_FORMAT_LE
Indicates little-endian, IEEE 754 floating point format.
Definition: logging_api.hpp:193
default_LogSubsystemInfo
struct LogSubsystemInfo default_LogSubsystemInfo
Default descriptive information for Logging subsystem.
Definition: logging_api.cpp:117
LogMessageRecord::threadId
uint64_t threadId
Thread Id of log event creator.
Definition: logging_api.hpp:1126
LogMessageRecord::AND_USE_STDERR
@ AND_USE_STDERR
Definition: logging_api.hpp:1072
LogManager::MAX_LOG_LINE_LENGTH
@ MAX_LOG_LINE_LENGTH
Default maximum length of a log line.
Definition: logging_api.hpp:610
LogManager::stripFilePrefix
static const char * stripFilePrefix[MAX_FILE_PREFIX_ENTRIES]
Definition: logging_api.hpp:584
IO_processBlockFP
int(* IO_processBlockFP)(SharedBufferAllocRecord *rec, class IO_Processor *controller)
Process a block of data received from an input source.
Definition: io_processor.hpp:69
logging_api.hpp
FARGOS Logging API.
EINTR
#define EINTR
Definition: tmp.o.cpp:93
Generated: Fri Jul 31 2020 18:19:14
Support Information