librnr  1.14.5
RoadNarrows Robotics Common Library 1
log.h File Reference

Logger declarations. More...

#include <stdio.h>
#include <stdarg.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include "rnr/rnrconfig.h"

Go to the source code of this file.

Macros

#define CONCAT_(x, y)   x ## y
 build concatenation operator
 
#define CONCAT(x, y)   CONCAT_(x, y)
 now concatenate
 
#define MKSTR_(x)   #x
 build token into string operator
 
#define MKSTR(x)   MKSTR_(x)
 now make string literal
 
#define LOGNS
 < default logging namespace More...
 
#define LOGNS_NAME   ""
 default logging preface string More...
 
#define LOGNS_PUT(id)   CONCAT(LOGNS, id)
 put identifier into namespace
 
#define LOGMOD
 default logging module name
 
#define LOG_PREFACE_TEXT   ""
 no logging preface
 
#define LOG_VAR_THRESHOLD   LOGNS_PUT(LogThresholdLevel)
 current threshold variable name
 
#define LOG_SET_THRESHOLD   LOGNS_PUT(LogSetThresholdLevel)
 set threshold function name
 
#define LOG_GET_THRESHOLD   LOGNS_PUT(LogGetThresholdLevel)
 get threshold function name
 
#define LOG_VAR_COLOR_EN   LOGNS_PUT(LogColorEnable)
 logging in color is [not] enabled
 
#define LOG_SET_LOGFILE   LogSetLogFile
 set output log file function name
 
#define LOG_GET_LOGFILE   LogGetLogFile
 get output log file function name
 
#define LOG_SET_COLOR_ENABLE   LogSetColorEnable
 enable/disable logging in color func name
 
#define LOG_SET_TIMESTAMP_ENABLE   LogSetTimestampEnable
 enable/disable logging timestamps func name
 
#define LOG_ATTACH_LOGFP   LogAttachLogFp
 attach file pointer as logging out stream
 
#define LOG_GET_LOGFP   LogGetLogFp
 get current logging out stream file pointer
 
#define LOGGER   LogPrintf
 logger function name
 
#define LOGGER_CALL   LogCallPrintf
 logger of "function call" function name
 
#define LOGGING_NA   -1
 logging not available (not compiled)
 
#define LOG_LEVEL_OFF   0
 turn off all non-error logging
 
#define LOG_LEVEL_ERROR   1
 errors
 
#define LOG_LEVEL_DIAG1   2
 diagnostic level 1
 
#define LOG_LEVEL_DIAG2   3
 diagnostic level 2
 
#define LOG_LEVEL_DIAG3   4
 diagnostic level 3
 
#define LOG_LEVEL_DIAG4   5
 diagnostic level 4
 
#define LOG_LEVEL_DIAG5   6
 diagnostic level 5
 
#define LOG_LEVEL_DFT   0
 default log level is off
 
#define LOGABLE(level)   ((level) <= LOG_VAR_THRESHOLD)
 Test if given level is logable at current threshold. More...
 
#define LOG_IN_COLOR()   (LOG_VAR_COLOR_EN)
 Test if logging in color.
 
#define LOG_WITH_TIMESTAMP()   (LOG_VAR_TIMESTAMP_EN)
 Test if logging includes timestamps.
 
#define LOG_FILENAME_STDERR   "stderr"
 'stderr' log filename
 
#define LOG_FILENAME_STDOUT   "stdout"
 'stdout' log filename
 
#define LOG_FILENAME_DFT   LOG_FILENAME_STDERR
 default log filename
 
#define LOG_FP_DFT   stderr
 default log out stream
 
#define LOG_COLOR_EN_DFT   true
 default is to log in color
 
#define LOG_TIMESTAMP_EN_DFT   true
 default is to include timestamps
 
#define LOGFUNCNAME   __func__
 function name
 
#define LOG_COLOR_PRE   "\033["
 color escape sequence prefix
 
#define LOG_COLOR_POST   "\033[0m"
 color escape sequence postfix
 
#define LOG_COLOR_RED   "0;31m"
 normal red
 
#define LOG_COLOR_GREEN   "0;32m"
 normal green
 
#define LOG_COLOR_YELLOW   "0;33m"
 normal yellow
 
#define LOG_COLOR_BLUE   "0;34m"
 normal blue
 
#define LOG_COLOR_MAGENTA   "0;35m"
 normal magenta
 
#define LOG_COLOR_CYAN   "0;36m"
 normal cyan
 
#define LOG_COLOR_LIGHT_RED   "1;31m"
 light red
 
#define LOG_COLOR_LIGHT_GREEN   "1;32m"
 light green
 
#define LOG_COLOR_LIGHT_YELLOW   "1;33m"
 light yellow
 
#define LOG_COLOR_LIGHT_BLUE   "1;34m"
 light blue
 
#define LOG_COLOR_LIGHT_MAGENTA   "1;35m"
 light magenta
 
#define LOG_COLOR_LIGHT_CYAN   "1;36m"
 light cyan
 
#define LOG_COLOR_ERROR   LOG_COLOR_PRE LOG_COLOR_RED
 error color
 
#define LOG_COLOR_WARN   LOG_COLOR_PRE LOG_COLOR_YELLOW
 warning color
 
#define LOG_COLOR_DIAG   LOG_COLOR_PRE LOG_COLOR_GREEN
 diagnostics color
 
#define LOG_PREFACE   LOG_PREFACE_TEXT
 loging preface string
 
#define LOG_PREFACE_PLAIN   LOG_PREFACE_TEXT
 loging preface with no color
 
#define LOGARGS_DIAG(level, fmt, ...)
 Standard diagnostic logging output arguments with compiled color. More...
 
#define LOGARGS_DIAG_PLAIN(level, fmt, ...)
 Standard diagnostic logging output arguments in plain text. More...
 
#define LOGARGS_WARN(fmt, ...)
 Standard warning logging output arguments with compiled color. More...
 
#define LOGARGS_WARN_PLAIN(fmt, ...)   LOG_PREFACE_PLAIN "Warning: %s[%d] " fmt, __FILE__, __LINE__, ##__VA_ARGS__
 Standard warning logging output arguments in plain text. More...
 
#define LOGARGS_ERR(fmt, ...)
 Standard error logging output arguments with compiled color. More...
 
#define LOGARGS_ERR_PLAIN(fmt, ...)   LOG_PREFACE_PLAIN "Error: %s[%d] " fmt, __FILE__, __LINE__, ##__VA_ARGS__
 Standard error logging output arguments in plain text. More...
 
#define LOGARGS_SYSERR(fmt, ...)
 Standard system error logging output arguments with compiled color. More...
 
#define LOGARGS_SYSERR_PLAIN(fmt, ...)
 Standard system error logging output arguments with compiled color. More...
 
#define LOGDIAG(level, fmt, ...)
 Standard Diagnostic logging. More...
 
#define LOGUSER(level, fmt, ...)   LOGDIAG(level+LOG_LEVEL_DIAG3+1, fmt, ##__VA_ARGS__)
 Standard User Diagnostic logging. More...
 
#define LOGDIAG5(fmt, ...)   LOGDIAG(LOG_LEVEL_DIAG5, fmt, ##__VA_ARGS__)
 Standard Diagnostic Level 5 logging. More...
 
#define LOGDIAG4(fmt, ...)   LOGDIAG(LOG_LEVEL_DIAG4, fmt, ##__VA_ARGS__)
 Standard Diagnostic Level 4 logging. More...
 
#define LOGDIAG3(fmt, ...)   LOGDIAG(LOG_LEVEL_DIAG3, fmt, ##__VA_ARGS__)
 Standard Diagnostic Level 3 logging. More...
 
#define LOGDIAG2(fmt, ...)   LOGDIAG(LOG_LEVEL_DIAG2, fmt, ##__VA_ARGS__)
 Standard Diagnostic Level 2 logging. More...
 
#define LOGDIAG1(fmt, ...)   LOGDIAG(LOG_LEVEL_DIAG1, fmt, ##__VA_ARGS__)
 Standard Diagnostic Level 1 logging. More...
 
#define LOGDIAGCALL(level, ...)
 Standard Diagnostic function call tracing. More...
 
#define LOGDIAG5CALL(...)   LOGDIAGCALL(LOG_LEVEL_DIAG5, ##__VA_ARGS__)
 Standard Diagnostic Level 5 function call tracing. More...
 
#define LOGDIAG4CALL(...)   LOGDIAGCALL(LOG_LEVEL_DIAG4, ##__VA_ARGS__)
 Standard Diagnostic Level 4 function call tracing. More...
 
#define LOGDIAG3CALL(...)   LOGDIAGCALL(LOG_LEVEL_DIAG3, ##__VA_ARGS__)
 Standard Diagnostic Level 3 function call tracing. More...
 
#define LOGDIAG2CALL(...)   LOGDIAGCALL(LOG_LEVEL_DIAG2, ##__VA_ARGS__)
 Standard Diagnostic Level 2 function call tracing. More...
 
#define LOGDIAG1CALL(...)   LOGDIAGCALL(LOG_LEVEL_DIAG1, ##__VA_ARGS__)
 Standard Diagnostic Level 1 function call tracing. More...
 
#define LOGWARN(fmt, ...)
 Standard Warning logging. More...
 
#define LOGERROR(fmt, ...)
 Standard Error logging. More...
 
#define LOGSYSERROR(fmt, ...)
 Standard System Error logging. More...
 
#define _VARFMT(var, fmt)   #var "=" fmt
 log Variable Format.
 
#define _TF(b)   ((b)? "true": "false")
 boolean to string format
 
#define _CHARFMT(var)   (isprint(var)? #var "='%c'": #var "=0x%02x")
 char format string
 
#define _TFMT(var, fmt)   #var "=" fmt, var
 Family of 2-tuple ("<varname>=<fmt>", <var>) variable logging formatters. More...
 
#define _TSTR(var)   _TFMT(var, "\"%s\"")
 string variable
 
#define _TLONG(var)   _TFMT(var, "%ld")
 long int (decimal)
 
#define _TULONG(var)   _TFMT(var, "%lu")
 unsigned long int (decimal)
 
#define _THEX(var)   _TFMT(var, "0x%x")
 int (hex)
 
#define _TINT(var)   _TFMT(var, "%d")
 int (decimal)
 
#define _TUINT(var)   _TFMT(var, "%u")
 unsigned int (decimal)
 
#define _TSHORT(var)   _TFMT(var, "%hd")
 short int (decimal)
 
#define _TUSHORT(var)   _TFMT(var, "%hu")
 unsigned short (decimal)
 
#define _TFLOAT(var)   _TFMT(var, "%f")
 float
 
#define _TPTR(var)   _TFMT(var, "%p")
 pointer
 
#define _TBOOL(var)   _VARFMT(var, "%s"), _TF(var)
 boolean
 
#define _TCHAR(var)   _CHARFMT(var), var
 character
 
#define _TVEC(var, i, fmt)   #var "[%d]=" fmt, i, var[i]
 vector variable
 
#define _TVEC_UINT(var, i)   _TVEC(var, i, "%u")
 unsigned vector variable
 
#define LFF   "%s()", LOGFUNCNAME
 
#define LFF_ARGS(fmt, ...)   "%s(" fmt "%s", LOGFUNCNAME, ##__VA_ARGS__, ")"
 Log formatter for function with arguments. More...
 
#define LFF_BADARG(var, fmt, postfmt, ...)   "%s(" #var "=" fmt "): " postfmt, LOGFUNCNAME, var, ##__VA_ARGS__
 Log formatter for function with a bad argument. More...
 
#define LFF_BADARG_VEC(var, i, fmt, postfmt, ...)   "%s(" #var "[%d]=" fmt "): " postfmt, LOGFUNCNAME, i, var[i], ##__VA_ARGS__
 Log formatter for function with a bad vector argument. More...
 
#define CHKPTR(p, ...)
 Checks validity of pointer. More...
 
#define CHKEXPR(val, expr, valfmt, ...)
 Checks validity of value against the given validation expression. More...
 
#define CHKEXPR_INT(val, expr, ...)   CHKEXPR(val, expr, "%d", ##__VA_ARGS__)
 check integer
 
#define CHKEXPR_STR(val, expr, ...)   CHKEXPR(val, expr, "'%s'", ##__VA_ARGS__)
 check string
 
#define CHKEXPR_LONG(val, expr, ...)   CHKEXPR(val, expr, "%ld", ##__VA_ARGS__)
 check long integer
 
#define CHKEXPR_ULONG(val, expr, ...)   CHKEXPR(val, expr, "%lu", ##__VA_ARGS__)
 check unsigned long integer
 
#define CHKEXPR_HEX(val, expr, ...)   CHKEXPR(val, expr, "0x%x", ##__VA_ARGS__)
 check integer hex
 
#define CHKEXPR_UINT(val, expr, ...)   CHKEXPR(val, expr, "%u", ##__VA_ARGS__)
 check unsigned integer
 
#define CHKEXPR_SHORT(val, expr, ...)   CHKEXPR(val, expr, "%hd",## __VA_ARGS__)
 check short integer
 
#define CHKEXPR_USHORT(val, expr, ...)   CHKEXPR(val, expr, "%hu", ##__VA_ARGS__)
 check unsigned short integer
 
#define CHKEXPR_PTR(val, expr, ...)   CHKEXPR(val, expr, "%p", ##__VA_ARGS__)
 check pointer
 
#define LOGNS_DEF_BLOCK
 If logging is defined is a different logging name space, then LOGNS_DEF must be included into the application or library.
 

Functions

int LogSetThresholdLevel (int nLevel)
 
int LogGetThresholdLevel ()
 
void LogSetColorEnable (bool_t enable)
 
void LogSetTimestampEnable (bool_t enable)
 
int LogSetLogFile (const char *sLogFileName)
 
const char * LogGetLogFile ()
 
void LogAttachLogFp (FILE *fp, const char *sFpFileName)
 
FILE * LogGetLogFp ()
 
void LogPrintf (const char *sFmt,...)
 
void LogCallPrintf (const char *sPreface, int nLevel, const char *sFile, int nLine, const char *sFuncName,...)
 

Variables

int LogThresholdLevel
 current logging threshold variable
 
bool_t LogColorEnable
 color logging is [not] enabled
 

Detailed Description

Logger declarations.

Logging supports error and diagnostics (debugging) reports to stderr or a specified file. Logging reporting is filtered by a simple threshold level.

The logging facilities are designed to support independent logging capabilities through namespaceing. Copy log.h and log.c to user application source tree and compile with LOGNS uniquely defined.

The Defined Loggging Thresholds
Define Threshold Description
LOGGING_NA -1 Logging is not compiled into the application.
See LOG_GET_THRESHOLD() to test level including this level.
LOG_LEVEL_OFF 0 Logging is turned off.
LOG_LEVEL_ERROR 1 Log only warnings and errors.
LOG_LEVEL_DIAG1 2 Log errors plus level 1 diagnostics.
LOG_LEVEL_DIAG2 3 Log errors plus level 1-2 diagnostics.
LOG_LEVEL_DIAG3 4 Log errors plus level 1-3 diagnostics.
LOG_LEVEL_DIAG4 5 Log errors plus level 1-4 diagnostics.
LOG_LEVEL_DIAG5 6 Log errors plus level 1-5 diagnostics.
User Defined ≥ 7 User defined loggging levels.
Coding Common Logging Macros
Macro Threshold Description
LOGWARN() 1 Log warning message.
LOGERROR() 1 Log error message.
LOGSYSERROR() 1 Log system error message.
The errno and associaed string will also be logged.
LOGDIAG1() 2 Log level 1 diagnostic message.
~ ~ ~
LOGDIAG5() 6 Log level 5 diagnostic message.
LOG_GET_THRESHOLD() - Get current logging level.
LOG_SET_THRESHOLD() - Set current logging level.
LOGFUNCNAME - Calling function or method name.
Special Make Defines
LOG
If defined, complile logging into an application.
Default: not defined.
LOGNS
Log namespace string. All external identifiers will be prefixed by LOGNS<id>. This is usefull, for example, if a program uses logging and is also linked with a library that also uses logging.
Default: <emptystring>
LOGMOD
If defined, all logging output will be prefaced with this string.
Default: LOGNS
LOG_LEVEL_DFT
Initial default logging threshold level.
Default: 0 (off)
See also
Page example_log under "Related Pages" for an example usage of logging.
Todo:
Define log class concepts whereby logging can be filtered by threshold and class.
LogClassSet(...), LogClassClear(), LogClassAdd(...), LogClassDel(...)
Class maps to a bit in a bitmap. All logging macros check loglevel and class bit.
Reserved names: 'all', 'none', 'common' (default)
Package
RoadNarrows Robotics Common Library 1
Library
librnr
File
include/rnr/log.h
Author
Robin Knight (robin.nosp@m..kni.nosp@m.ght@r.nosp@m.oadn.nosp@m.arrow.nosp@m.s.co.nosp@m.m)
License
MIT
EULA
See the README and EULA files for any copyright and licensing information.

Definition in file log.h.

Macro Definition Documentation

#define _TFMT (   var,
  fmt 
)    #var "=" fmt, var

Family of 2-tuple ("<varname>=<fmt>", <var>) variable logging formatters.

The _T*() macros are used to create a format string, variable pair of the form: "<varname>=<fmt>",<var>

Parameters
varVariable identifier.
fmtFormat string to print variable.
Note
Intended use are calls to the LOGDIAGxCALL() macros, although can be used anywhere, although only once per each LOGDIAGx(), LOGERROR(), or LOGSYSERROR() call.
See also
_VARFMT() for a more general varaible formatter.raw Format,Variable Pair

Definition at line 577 of file log.h.

#define CHKEXPR (   val,
  expr,
  valfmt,
  ... 
)
Value:
do \
{ \
if( !(expr) ) \
{ \
LOGERROR(_VARFMT(val, valfmt) ": failed check: %s", val, #expr); \
return __VA_ARGS__; \
} \
} while(0)
#define LOGERROR(fmt,...)
Standard Error logging.
Definition: log.h:488
#define _VARFMT(var, fmt)
log Variable Format.
Definition: log.h:555

Checks validity of value against the given validation expression.

The CHKEXPR*() macros are used validate a value against an expression. If the expression evaluates to false, then log an error message and return from the embedding functin with the given (optional) error return code.

Parameters
valValue identifier to check.
exprValidation expression to evaluate.
valfmtValue format string to use on error.
...Error return code (optional).

Definition at line 673 of file log.h.

#define CHKPTR (   p,
  ... 
)
Value:
do \
{ \
if( (p) == NULL ) \
{ \
LOGERROR(_TPTR(p)); return __VA_ARGS__; \
} \
} while(0)
#define NULL
null pointer
Definition: rnrconfig.h:199
#define LOGERROR(fmt,...)
Standard Error logging.
Definition: log.h:488
#define _TPTR(var)
pointer
Definition: log.h:587

Checks validity of pointer.

If null then log error and return from the embedding function with given (optional) error return code.

Parameters
pPointer that should not be NULL.
...Error return code (optional).

Definition at line 651 of file log.h.

Referenced by AssocMapVoidXtoY(), AssocMapVoidYtoX(), ConfigDbGetName(), ConfigDbRead(), ConfigDbReadFp(), ConfigDbSetName(), ConfigSectionNew(), DListVoidAppend(), DListVoidDeleteNode(), DListVoidDeleteNodeAt(), DListVoidFindNode(), DListVoidGetNodeAt(), DListVoidInsert(), DListVoidIterNodeFirst(), DListVoidIterNodeLast(), DListVoidIterNodeNext(), DListVoidIterNodePrev(), DListVoidPrepend(), DListVoidUnlinkDataAt(), DListVoidUnlinkNodeAt(), SocketAttrGetClientData(), SocketAttrGetFlavor(), SocketAttrGetLocalName(), SocketAttrGetPort(), SocketAttrGetRemoteName(), SocketAttrGetSd(), SocketAttrHasFlavor(), SocketAttrSetClientData(), SocketAttrSetFlavor(), SocketAttrSetLocalName(), SocketAttrSetNonBlocking(), SocketAttrSetPort(), SocketAttrSetRemoteName(), SocketAttrSetSd(), SocketBufClear(), SocketBufGetBuf(), SocketBufGetLen(), SocketBufGetRawBuf(), SocketBufGetSize(), SocketBufNewBuf(), SocketBufSetBuf(), SocketClose(), SocketRead(), SocketWrite(), SockSetActivate(), SockSetAdd(), SockSetChkSd(), SockSetIterFirst(), SockSetIterNext(), SockSetPutOnHold(), SockSetRemove(), and SockSetSelect().

#define LFF   "%s()", LOGFUNCNAME

function name w/ parens

Definition at line 597 of file log.h.

#define LFF_ARGS (   fmt,
  ... 
)    "%s(" fmt "%s", LOGFUNCNAME, ##__VA_ARGS__, ")"

Log formatter for function with arguments.

Format: function(var=val, ...)

Parameters
fmtFormat string to print function arguments.
...Arguments to fmt string.

Definition at line 607 of file log.h.

#define LFF_BADARG (   var,
  fmt,
  postfmt,
  ... 
)    "%s(" #var "=" fmt "): " postfmt, LOGFUNCNAME, var, ##__VA_ARGS__

Log formatter for function with a bad argument.

Format: function(var=val): errmsg

Parameters
varVariable identifier.
fmtFormat string to print function argument.
postfmtFormat string to print after function string.
...Arguments to postfmt string

Definition at line 620 of file log.h.

#define LFF_BADARG_VEC (   var,
  i,
  fmt,
  postfmt,
  ... 
)    "%s(" #var "[%d]=" fmt "): " postfmt, LOGFUNCNAME, i, var[i], ##__VA_ARGS__

Log formatter for function with a bad vector argument.

Format: function(var[i]=val): errmsg

Parameters
varVector variable identifier.
iVariable index.
fmtFormat string to print function argument.
postfmtFormat string to print after function string.
...Arguments to postfmt string

Definition at line 634 of file log.h.

#define LOGABLE (   level)    ((level) <= LOG_VAR_THRESHOLD)

Test if given level is logable at current threshold.

Parameters
levelLevel to test.

Definition at line 195 of file log.h.

Referenced by init(), and NewSearchPathDList().

#define LOGARGS_DIAG (   level,
  fmt,
  ... 
)
Value:
LOG_PREFACE LOG_COLOR_DIAG "Diag%d: %s[%d] " LOG_COLOR_POST fmt, \
(level-1), __FILE__, __LINE__, ##__VA_ARGS__
#define LOG_COLOR_POST
color escape sequence postfix
Definition: log.h:231
#define LOG_PREFACE
loging preface string
Definition: log.h:253
#define LOG_COLOR_DIAG
diagnostics color
Definition: log.h:247

Standard diagnostic logging output arguments with compiled color.

Parameters
levelLoggging level.
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 269 of file log.h.

Referenced by LOG_SET_THRESHOLD().

#define LOGARGS_DIAG_PLAIN (   level,
  fmt,
  ... 
)
Value:
LOG_PREFACE_PLAIN "Diag%d: %s[%d] " fmt, \
(level-1), __FILE__, __LINE__, ##__VA_ARGS__
#define LOG_PREFACE_PLAIN
loging preface with no color
Definition: log.h:256

Standard diagnostic logging output arguments in plain text.

Parameters
levelLoggging level.
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 279 of file log.h.

Referenced by LOG_SET_THRESHOLD().

#define LOGARGS_ERR (   fmt,
  ... 
)
Value:
__FILE__, __LINE__, ##__VA_ARGS__
#define LOG_COLOR_ERROR
error color
Definition: log.h:245
#define LOG_COLOR_POST
color escape sequence postfix
Definition: log.h:231
#define LOG_PREFACE
loging preface string
Definition: log.h:253

Standard error logging output arguments with compiled color.

Parameters
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 305 of file log.h.

#define LOGARGS_ERR_PLAIN (   fmt,
  ... 
)    LOG_PREFACE_PLAIN "Error: %s[%d] " fmt, __FILE__, __LINE__, ##__VA_ARGS__

Standard error logging output arguments in plain text.

Parameters
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 314 of file log.h.

#define LOGARGS_SYSERR (   fmt,
  ... 
)
Value:
LOG_PREFACE LOG_COLOR_ERROR "Error: %s[%d] " LOG_COLOR_POST "%s(errno=%d): " \
fmt, __FILE__, __LINE__, strerror(errno), errno, ##__VA_ARGS__
#define LOG_COLOR_ERROR
error color
Definition: log.h:245
#define LOG_COLOR_POST
color escape sequence postfix
Definition: log.h:231
#define LOG_PREFACE
loging preface string
Definition: log.h:253

Standard system error logging output arguments with compiled color.

Parameters
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 322 of file log.h.

#define LOGARGS_SYSERR_PLAIN (   fmt,
  ... 
)
Value:
LOG_PREFACE_PLAIN "Error: %s[%d] " "%s(errno=%d): " fmt, \
__FILE__, __LINE__, strerror(errno), errno, ##__VA_ARGS__
#define LOG_PREFACE_PLAIN
loging preface with no color
Definition: log.h:256

Standard system error logging output arguments with compiled color.

Parameters
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 331 of file log.h.

#define LOGARGS_WARN (   fmt,
  ... 
)
Value:
LOG_PREFACE LOG_COLOR_WARN "Warning: %s[%d] " LOG_COLOR_POST fmt, \
__FILE__, __LINE__, ##__VA_ARGS__
#define LOG_COLOR_POST
color escape sequence postfix
Definition: log.h:231
#define LOG_PREFACE
loging preface string
Definition: log.h:253
#define LOG_COLOR_WARN
warning color
Definition: log.h:246

Standard warning logging output arguments with compiled color.

Parameters
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 288 of file log.h.

#define LOGARGS_WARN_PLAIN (   fmt,
  ... 
)    LOG_PREFACE_PLAIN "Warning: %s[%d] " fmt, __FILE__, __LINE__, ##__VA_ARGS__

Standard warning logging output arguments in plain text.

Parameters
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 297 of file log.h.

#define LOGDIAG (   level,
  fmt,
  ... 
)
Value:
do \
{ \
if( LOGABLE(level) ) \
{ \
if( LOG_IN_COLOR() ) \
{ \
LOGGER(LOGARGS_DIAG(level, fmt), ##__VA_ARGS__); \
} \
else \
{ \
LOGGER(LOGARGS_DIAG_PLAIN(level, fmt), ##__VA_ARGS__); \
} \
} \
} while(0)
#define LOGARGS_DIAG(level, fmt,...)
Standard diagnostic logging output arguments with compiled color.
Definition: log.h:269
#define LOGARGS_DIAG_PLAIN(level, fmt,...)
Standard diagnostic logging output arguments in plain text.
Definition: log.h:279
#define LOGABLE(level)
Test if given level is logable at current threshold.
Definition: log.h:195
#define LOG_IN_COLOR()
Test if logging in color.
Definition: log.h:200
#define LOGGER
logger function name
Definition: log.h:170

Standard Diagnostic logging.

Parameters
levelLoggging level.
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 348 of file log.h.

#define LOGDIAG1 (   fmt,
  ... 
)    LOGDIAG(LOG_LEVEL_DIAG1, fmt, ##__VA_ARGS__)

Standard Diagnostic Level 1 logging.

Parameters
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 407 of file log.h.

Referenced by init(), LOG_SET_LOGFILE(), runExample(), and threadmain().

#define LOGDIAG1CALL (   ...)    LOGDIAGCALL(LOG_LEVEL_DIAG1, ##__VA_ARGS__)

Standard Diagnostic Level 1 function call tracing.

Parameters
...Optional argument_format,argument pairs.

Definition at line 460 of file log.h.

Referenced by logtest_num1().

#define LOGDIAG2 (   fmt,
  ... 
)    LOGDIAG(LOG_LEVEL_DIAG2, fmt, ##__VA_ARGS__)

Standard Diagnostic Level 2 logging.

Parameters
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 400 of file log.h.

Referenced by logtest_num1().

#define LOGDIAG2CALL (   ...)    LOGDIAGCALL(LOG_LEVEL_DIAG2, ##__VA_ARGS__)

Standard Diagnostic Level 2 function call tracing.

Parameters
...Optional argument_format,argument pairs.

Definition at line 454 of file log.h.

Referenced by logtest_num2().

#define LOGDIAG3 (   fmt,
  ... 
)    LOGDIAG(LOG_LEVEL_DIAG3, fmt, ##__VA_ARGS__)

Standard Diagnostic Level 3 logging.

Parameters
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 393 of file log.h.

Referenced by ConfigDbNew(), shm_close(), shm_mutex_init(), shm_open(), and SocketAttrSetNonBlocking().

#define LOGDIAG3CALL (   ...)    LOGDIAGCALL(LOG_LEVEL_DIAG3, ##__VA_ARGS__)

Standard Diagnostic Level 3 function call tracing.

Parameters
...Optional argument_format,argument pairs.

Definition at line 448 of file log.h.

#define LOGDIAG5 (   fmt,
  ... 
)    LOGDIAG(LOG_LEVEL_DIAG5, fmt, ##__VA_ARGS__)

Standard Diagnostic Level 5 logging.

Parameters
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 379 of file log.h.

#define LOGDIAG5CALL (   ...)    LOGDIAGCALL(LOG_LEVEL_DIAG5, ##__VA_ARGS__)

Standard Diagnostic Level 5 function call tracing.

Parameters
...Optional argument_format,argument pairs.

Definition at line 436 of file log.h.

#define LOGDIAGCALL (   level,
  ... 
)
Value:
do \
{ \
if( LOGABLE(level) ) \
{ \
if( LOG_IN_COLOR() ) \
{ \
LOGGER_CALL(LOG_PREFACE, level, __FILE__, __LINE__, \
LOGFUNCNAME, ##__VA_ARGS__, NULL, 0); \
} \
else \
{ \
LOGGER_CALL(LOG_PREFACE_PLAIN, level, __FILE__, __LINE__, \
LOGFUNCNAME, ##__VA_ARGS__, NULL, 0); \
} \
} \
} while(0)
#define LOG_PREFACE_PLAIN
loging preface with no color
Definition: log.h:256
#define NULL
null pointer
Definition: rnrconfig.h:199
#define LOGFUNCNAME
function name
Definition: log.h:225
#define LOGABLE(level)
Test if given level is logable at current threshold.
Definition: log.h:195
#define LOG_IN_COLOR()
Test if logging in color.
Definition: log.h:200
#define LOG_PREFACE
loging preface string
Definition: log.h:253
#define LOGGER_CALL
logger of "function call" function name
Definition: log.h:172

Standard Diagnostic function call tracing.

Parameters
levelLoggging level.
...Optional argument_format,argument pairs.

Definition at line 414 of file log.h.

#define LOGERROR (   fmt,
  ... 
)
Value:
do \
{ \
{ \
if( LOG_IN_COLOR() ) \
{ \
LOGGER(LOGARGS_ERR(fmt), ##__VA_ARGS__); \
} \
else \
{ \
LOGGER(LOGARGS_ERR_PLAIN(fmt), ##__VA_ARGS__); \
} \
} \
} while(0)
#define LOGARGS_ERR(fmt,...)
Standard error logging output arguments with compiled color.
Definition: log.h:305
#define LOGABLE(level)
Test if given level is logable at current threshold.
Definition: log.h:195
#define LOG_IN_COLOR()
Test if logging in color.
Definition: log.h:200
#define LOGARGS_ERR_PLAIN(fmt,...)
Standard error logging output arguments in plain text.
Definition: log.h:314
#define LOG_LEVEL_ERROR
errors
Definition: log.h:180
#define LOGGER
logger function name
Definition: log.h:170

Standard Error logging.

Parameters
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 488 of file log.h.

Referenced by ConfigDbNew(), ConfigDbReadFp(), ConfigGetDouble(), ConfigGetLong(), ConfigSectionDelete(), ConfigSectionNew(), DListVoidDeleteNode(), DListVoidGetNodeAt(), logtest_num2(), main(), NewJoinedPath(), NewSearchPathDList(), NewSearchPathExpanded(), OptsPrintf(), runExample(), runlogtests(), SearchPathIterFirst(), SearchPathIterNew(), shm_close(), shm_mutex_init(), shm_mutex_lock(), shm_mutex_trylock(), shm_mutex_unlock(), shm_open(), SocketAccept(), SocketOpenTcpConnection(), SocketOpenTcpListener(), SocketOpenUdp(), SocketRead(), SocketThisHostName(), SocketWrite(), SocketWriteAll(), SockResolveHostName(), SockSetChkSd(), and SockSetSelect().

#define LOGNS

< default logging namespace

default namespace preface token

Definition at line 116 of file log.h.

#define LOGNS_NAME   ""

default logging preface string

default namespace string name

Definition at line 117 of file log.h.

#define LOGSYSERROR (   fmt,
  ... 
)
Value:
do \
{ \
{ \
int errsave = errno; \
if( LOG_IN_COLOR() ) \
{ \
LOGGER(LOGARGS_SYSERR(fmt), ##__VA_ARGS__); \
} \
else \
{ \
LOGGER(LOGARGS_SYSERR_PLAIN(fmt), ##__VA_ARGS__); \
} \
errno = errsave; \
} \
} while(0)
#define LOGABLE(level)
Test if given level is logable at current threshold.
Definition: log.h:195
#define LOG_IN_COLOR()
Test if logging in color.
Definition: log.h:200
#define LOGARGS_SYSERR(fmt,...)
Standard system error logging output arguments with compiled color.
Definition: log.h:322
#define LOGARGS_SYSERR_PLAIN(fmt,...)
Standard system error logging output arguments with compiled color.
Definition: log.h:331
#define LOG_LEVEL_ERROR
errors
Definition: log.h:180
#define LOGGER
logger function name
Definition: log.h:170

Standard System Error logging.

Parameters
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 509 of file log.h.

Referenced by ConfigDbRead(), createThreads(), LOG_SET_LOGFILE(), logtest_num2(), shm_close(), shm_mutex_create(), shm_mutex_init(), shm_open(), SocketAccept(), SocketAddrNameInet(), SocketAttrSetLocalName(), SocketAttrSetNonBlocking(), SocketClose(), SocketOpenTcpConnection(), SocketOpenTcpListener(), SocketOpenUdp(), SocketRead(), SocketThisHostName(), SocketWrite(), and SockSetSelect().

#define LOGUSER (   level,
  fmt,
  ... 
)    LOGDIAG(level+LOG_LEVEL_DIAG3+1, fmt, ##__VA_ARGS__)

Standard User Diagnostic logging.

Parameters
levelLoggging user level.
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.
See also
LOGDIAG()

Definition at line 371 of file log.h.

#define LOGWARN (   fmt,
  ... 
)
Value:
do \
{ \
{ \
if( LOG_IN_COLOR() ) \
{ \
LOGGER(LOGARGS_WARN(fmt), ##__VA_ARGS__); \
} \
else \
{ \
LOGGER(LOGARGS_WARN_PLAIN(fmt), ##__VA_ARGS__); \
} \
} \
} while(0)
#define LOGARGS_WARN(fmt,...)
Standard warning logging output arguments with compiled color.
Definition: log.h:288
#define LOGARGS_WARN_PLAIN(fmt,...)
Standard warning logging output arguments in plain text.
Definition: log.h:297
#define LOGABLE(level)
Test if given level is logable at current threshold.
Definition: log.h:195
#define LOG_IN_COLOR()
Test if logging in color.
Definition: log.h:200
#define LOG_LEVEL_ERROR
errors
Definition: log.h:180
#define LOGGER
logger function name
Definition: log.h:170

Standard Warning logging.

Parameters
fmtOptional specifics format string.
...Optional specific variable arguments for fmt.

Definition at line 467 of file log.h.

Referenced by logtest_num2().