CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
Log Message Macros

Macros

#define logStr(level, str)   _logStr_##level(LOG_##level, LogDefault, str)
 
#define logStrC(level, cat, str)   _logStr_##level(LOG_##level, cat, str)
 
#define logFmt(level, fmt, ...)
 
#define logFmtC(level, cat, fmt, ...)
 

Detailed Description

These macros provide the primary interface for logging messages. They compile to no-ops for levels that are disabled based on DEBUG_LEVEL, ensuring zero overhead for disabled log levels.

Debug Level Filtering:

Dev variants: The Dev prefix variants (e.g., logStr(DevInfo, ...)) are only compiled in development builds and map to their corresponding regular levels in production.

Macro Definition Documentation

◆ logFmt

#define logFmt (   level,
  fmt,
  ... 
)
Value:
_logFmt_##level(LOG_##level, \
fmt, \
count_macro_args(__VA_ARGS__), \
((stvar[]) { __VA_ARGS__ }))
LogCategory * LogDefault
Default log category used when no category is specified.
#define stvar(typen, val)
Definition stvar.h:153
#define count_macro_args(...)
Definition args.h:81

void logFmt(level, fmt, ...)

Log a formatted message using the default category

Parameters
levelLog level without LOG_ prefix (e.g., Info, Warn, Error)
fmtFormat string (see Formatting for format syntax)
...Format arguments wrapped in stvar()
logFmt(Info, _S"Connection from ${string}:${int}",
stvar(string, hostname), stvar(int32, port));
logFmt(Warn, _S"Invalid value: ${int}", stvar(int32, value));
#define logFmt(level, fmt,...)
Definition log.h:260
#define _S
Creates a static ASCII string from a string literal.
Definition strbase.h:392

Definition at line 260 of file log.h.

◆ logFmtC

#define logFmtC (   level,
  cat,
  fmt,
  ... 
)
Value:
_logFmt_##level(LOG_##level, \
cat, \
fmt, \
count_macro_args(__VA_ARGS__), \
((stvar[]) { __VA_ARGS__ }))

void logFmtC(level, cat, fmt, ...)

Log a formatted message with a specific category

Parameters
levelLog level without LOG_ prefix
catLogCategory pointer
fmtFormat string
...Format arguments wrapped in stvar()
LogCategory *dbcat = logCreateCat(_S"Database", false);
logFmtC(Warn, dbcat, _S"Query took ${int}ms", stvar(int32, elapsed));
LogCategory * logCreateCat(strref name, bool priv)
#define logFmtC(level, cat, fmt,...)
Definition log.h:278

Definition at line 278 of file log.h.

◆ logStr

#define logStr (   level,
  str 
)    _logStr_##level(LOG_##level, LogDefault, str)

void logStr(level, str)

Log a string message using the default category

Parameters
levelLog level without LOG_ prefix (e.g., Info, Warn, Error)
strString or string reference to log
logStr(Info, _S"Application started");
logStr(Error, errorMessage);
#define logStr(level, str)
Definition log.h:235

Definition at line 235 of file log.h.

◆ logStrC

#define logStrC (   level,
  cat,
  str 
)    _logStr_##level(LOG_##level, cat, str)

void logStrC(level, cat, str)

Log a string message with a specific category

Parameters
levelLog level without LOG_ prefix (e.g., Info, Warn, Error)
catLogCategory pointer
strString or string reference to log
LogCategory *netcat = logCreateCat(_S"Network", false);
logStrC(Info, netcat, _S"Connection established");
#define logStrC(level, cat, str)
Definition log.h:247

Definition at line 247 of file log.h.