|
libcmutils 0.6.5
Multi-platform C99 utility library
|
Data Structures | |
| struct | CMUTIL_ConfLogger |
| Logger configuration object. More... | |
| struct | CMUTIL_Logger |
| Logger object. More... | |
| struct | CMUTIL_LogAppender |
| Log appender object. More... | |
| struct | CMUTIL_LogSystem |
| Log system object. More... | |
Macros | |
| #define | CMUTIL_LogDefine(name) |
| Define a logger for the current source file. | |
| #define | CMLogIsEnabled(level) CMUTIL_LogIsEnabled(g__CMUTIL_GetLogger(),level) |
| Macro to check if logging is enabled for the specified log level. | |
| #define | CMUTIL_Log__(level, stack, f, ...) |
| Log a message with the specified log level and stack trace option. | |
| #define | CMUTIL_Log2__(level, stack, f, ...) |
| Log a message with the specified log level and stack trace option. | |
| #define | CMLogTrace(f, ...) CMUTIL_Log__(Trace,False,f,##__VA_ARGS__) |
| Log a message at the Trace level. | |
| #define | CMLogTraceS(f, ...) CMUTIL_Log__(Trace,True ,f,##__VA_ARGS__) |
| Log a message at the Trace level with stack trace. | |
| #define | CMLogDebug(f, ...) CMUTIL_Log__(Debug,False,f,##__VA_ARGS__) |
| Log a message at the Debug level. | |
| #define | CMLogDebugS(f, ...) CMUTIL_Log__(Debug,True ,f,##__VA_ARGS__) |
| Log a message at the Debug level with stack trace. | |
| #define | CMLogInfo(f, ...) CMUTIL_Log__(Info ,False,f,##__VA_ARGS__) |
| Log a message at the Info level. | |
| #define | CMLogInfoS(f, ...) CMUTIL_Log__(Info ,True ,f,##__VA_ARGS__) |
| Log a message at the Info level with stack trace. | |
| #define | CMLogWarn(f, ...) CMUTIL_Log__(Warn ,False,f,##__VA_ARGS__) |
| Log a message at the Warn level. | |
| #define | CMLogWarnS(f, ...) CMUTIL_Log__(Warn ,True ,f,##__VA_ARGS__) |
| Log a message at the Warn level with stack trace. | |
| #define | CMLogError(f, ...) CMUTIL_Log__(Error,False,f,##__VA_ARGS__) |
| Log a message at the Error level. | |
| #define | CMLogErrorS(f, ...) CMUTIL_Log__(Error,True ,f,##__VA_ARGS__) |
| Log a message at the Error level with stack trace. | |
| #define | CMLogFatal(f, ...) CMUTIL_Log__(Fatal,False,f,##__VA_ARGS__) |
| Log a message at the Fatal level. | |
| #define | CMLogFatalS(f, ...) CMUTIL_Log__(Fatal,True ,f,##__VA_ARGS__) |
| Log a message at the Fatal level with stack trace. | |
| #define | CMLog(l, f, ...) CMUTIL_Log2__(l,False,f,##__VA_ARGS__) |
| Log a message with the specified log level. | |
| #define | CMLogS(l, f, ...) CMUTIL_Log2__(l,True ,f,##__VA_ARGS__) |
| Log a message with the specified log level and stack trace. | |
Enumerations | |
| enum | CMLogLevel { CMLogLevel_Trace = 0 , CMLogLevel_Debug , CMLogLevel_Info , CMLogLevel_Warn , CMLogLevel_Error , CMLogLevel_Fatal } |
| Log severity levels. More... | |
| enum | CMLogTerm { CMLogTerm_Year = 0 , CMLogTerm_Month , CMLogTerm_Date , CMLogTerm_Hour , CMLogTerm_Minute } |
| Log rolling terms. More... | |
Functions | |
| CMUTIL_LogAppender * | CMUTIL_LogConsoleAppenderCreate (const char *name, const char *pattern, CMBool use_stderr) |
| Create a console log appender. | |
| CMUTIL_LogAppender * | CMUTIL_LogFileAppenderCreate (const char *name, const char *fpath, const char *pattern) |
| Create a file log appender. | |
| CMUTIL_LogAppender * | CMUTIL_LogRollingFileAppenderCreate (const char *name, const char *fpath, CMLogTerm logterm, const char *rollpath, const char *pattern) |
| Create a rolling file log appender. | |
| CMUTIL_LogAppender * | CMUTIL_LogSocketAppenderCreate (const char *name, const char *accept_host, int listen_port, const char *pattern) |
| Create a socket log appender. | |
| void | CMUTIL_LogFallback (CMLogLevel level, const char *file, int line, const char *fmt,...) |
| Fallback logging function when no logger is available. | |
| CMBool | CMUTIL_LogIsEnabled (CMUTIL_Logger *logger, CMLogLevel level) |
| Check if logging is enabled for the specified log level. | |
| CMUTIL_LogSystem * | CMUTIL_LogSystemCreate (void) |
| Create a new log system object. | |
| CMUTIL_LogSystem * | CMUTIL_LogSystemConfigureFomJson (const char *jsonfile) |
| Configure the log system from a JSON configuration file. | |
| CMUTIL_LogSystem * | CMUTIL_LogSystemGet (void) |
| Get the current global log system. | |
| void | CMUTIL_LogSystemSet (CMUTIL_LogSystem *lsys) |
| Set the global log system. | |
| #define CMUTIL_LogDefine | ( | name | ) |
Define a logger for the current source file.
This macro defines a static logger instance for the current source file with the specified name. It provides a function to retrieve the logger instance, creating it if it does not already exist or if the log system has changed.
| name | The name of the logger. |
| #define CMLogIsEnabled | ( | level | ) | CMUTIL_LogIsEnabled(g__CMUTIL_GetLogger(),level) |
Macro to check if logging is enabled for the specified log level.
This macro checks whether logging is enabled for the given log level in the default logger.
| level | The log level to check. |
| #define CMUTIL_Log__ | ( | level, | |
| stack, | |||
| f, | |||
| ... | |||
| ) |
Log a message with the specified log level and stack trace option.
This macro logs a message at the specified log level, including the source file name, line number, and optionally a stack trace.
| level | The simple log level for the message. |
| stack | A boolean indicating whether to include a stack trace. |
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| #define CMUTIL_Log2__ | ( | level, | |
| stack, | |||
| f, | |||
| ... | |||
| ) |
Log a message with the specified log level and stack trace option.
This macro logs a message at the specified log level, including the source file name, line number, and optionally a stack trace.
| level | The full log level name for the message. |
| stack | A boolean indicating whether to include a stack trace. |
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| #define CMLogTrace | ( | f, | |
| ... | |||
| ) | CMUTIL_Log__(Trace,False,f,##__VA_ARGS__) |
Log a message at the Trace level.
This macro logs a message at the Trace level, including the source file name and line number.
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| #define CMLogTraceS | ( | f, | |
| ... | |||
| ) | CMUTIL_Log__(Trace,True ,f,##__VA_ARGS__) |
Log a message at the Trace level with stack trace.
This macro logs a message at the Trace level, including the source file name, line number, and a stack trace.
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| #define CMLogDebug | ( | f, | |
| ... | |||
| ) | CMUTIL_Log__(Debug,False,f,##__VA_ARGS__) |
Log a message at the Debug level.
This macro logs a message at the Debug level, including the source file name and line number.
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| #define CMLogDebugS | ( | f, | |
| ... | |||
| ) | CMUTIL_Log__(Debug,True ,f,##__VA_ARGS__) |
Log a message at the Debug level with stack trace.
This macro logs a message at the Debug level, including the source file name, line number, and a stack trace.
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| #define CMLogInfo | ( | f, | |
| ... | |||
| ) | CMUTIL_Log__(Info ,False,f,##__VA_ARGS__) |
Log a message at the Info level.
This macro logs a message at the Info level, including the source file name and line number.
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| #define CMLogInfoS | ( | f, | |
| ... | |||
| ) | CMUTIL_Log__(Info ,True ,f,##__VA_ARGS__) |
Log a message at the Info level with stack trace.
This macro logs a message at the Info level, including the source file name, line number, and a stack trace.
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| #define CMLogWarn | ( | f, | |
| ... | |||
| ) | CMUTIL_Log__(Warn ,False,f,##__VA_ARGS__) |
Log a message at the Warn level.
This macro logs a message at the Warn level, including the source file name and line number.
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| #define CMLogWarnS | ( | f, | |
| ... | |||
| ) | CMUTIL_Log__(Warn ,True ,f,##__VA_ARGS__) |
Log a message at the Warn level with stack trace.
This macro logs a message at the Warn level, including the source file name, line number, and a stack trace.
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| #define CMLogError | ( | f, | |
| ... | |||
| ) | CMUTIL_Log__(Error,False,f,##__VA_ARGS__) |
Log a message at the Error level.
This macro logs a message at the Error level, including the source file name and line number.
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| #define CMLogErrorS | ( | f, | |
| ... | |||
| ) | CMUTIL_Log__(Error,True ,f,##__VA_ARGS__) |
Log a message at the Error level with stack trace.
This macro logs a message at the Error level, including the source file name, line number, and a stack trace.
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| #define CMLogFatal | ( | f, | |
| ... | |||
| ) | CMUTIL_Log__(Fatal,False,f,##__VA_ARGS__) |
Log a message at the Fatal level.
This macro logs a message at the Fatal level, including the source file name and line number.
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| #define CMLogFatalS | ( | f, | |
| ... | |||
| ) | CMUTIL_Log__(Fatal,True ,f,##__VA_ARGS__) |
Log a message at the Fatal level with stack trace.
This macro logs a message at the Fatal level, including the source file name, line number, and a stack trace.
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| #define CMLog | ( | l, | |
| f, | |||
| ... | |||
| ) | CMUTIL_Log2__(l,False,f,##__VA_ARGS__) |
Log a message with the specified log level.
This macro logs a message at the specified log level, including the source file name, line number.
| l | The full log level for the message. |
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| #define CMLogS | ( | l, | |
| f, | |||
| ... | |||
| ) | CMUTIL_Log2__(l,True ,f,##__VA_ARGS__) |
Log a message with the specified log level and stack trace.
This macro logs a message at the specified log level, including the source file name, line number, and stack trace.
| l | The full log level for the message. |
| f | The format string for the log message. |
| ... | Additional arguments for the format string. |
| enum CMLogLevel |
Log severity levels.
| enum CMLogTerm |
| CMUTIL_LogAppender * CMUTIL_LogConsoleAppenderCreate | ( | const char * | name, |
| const char * | pattern, | ||
| CMBool | use_stderr | ||
| ) |
Create a console log appender.
| name | The name of the log appender. |
| pattern | The log message pattern. |
| use_stderr | Whether to use stderr instead of stdout for logging. |
| CMUTIL_LogAppender * CMUTIL_LogFileAppenderCreate | ( | const char * | name, |
| const char * | fpath, | ||
| const char * | pattern | ||
| ) |
Create a file log appender.
| name | The name of the log appender. |
| fpath | The file path for the log file. |
| pattern | The log message pattern. |
| CMUTIL_LogAppender * CMUTIL_LogRollingFileAppenderCreate | ( | const char * | name, |
| const char * | fpath, | ||
| CMLogTerm | logterm, | ||
| const char * | rollpath, | ||
| const char * | pattern | ||
| ) |
Create a rolling file log appender.
| name | The name of the log appender. |
| fpath | The file path for the log file. |
| logterm | The log rolling term. |
| rollpath | The roll file path pattern. |
| pattern | The log message pattern. |
| CMUTIL_LogAppender * CMUTIL_LogSocketAppenderCreate | ( | const char * | name, |
| const char * | accept_host, | ||
| int | listen_port, | ||
| const char * | pattern | ||
| ) |
Create a socket log appender.
| name | The name of the log appender. |
| accept_host | Listen host address.(0.0.0.0 for any address) |
| listen_port | Listen port number. |
| pattern | The log message pattern. |
| void CMUTIL_LogFallback | ( | CMLogLevel | level, |
| const char * | file, | ||
| int | line, | ||
| const char * | fmt, | ||
| ... | |||
| ) |
Fallback logging function when no logger is available.
| level | Log level. |
| file | Source file name. |
| line | Line number in source file. |
| fmt | Format string for the log message. |
| ... | Additional arguments for the format string. |
| CMBool CMUTIL_LogIsEnabled | ( | CMUTIL_Logger * | logger, |
| CMLogLevel | level | ||
| ) |
Check if logging is enabled for the specified log level.
This function checks whether logging is enabled for the given log level in the specified logger.
| logger | A pointer to the CMUTIL_Logger object. |
| level | The log level to check. |
| CMUTIL_LogSystem * CMUTIL_LogSystemCreate | ( | void | ) |
Create a new log system object.
| CMUTIL_LogSystem * CMUTIL_LogSystemConfigureFomJson | ( | const char * | jsonfile | ) |
Configure the log system from a JSON configuration file.
The result is installed as the global log system, replacing and destroying whatever was installed before, so the return value does not have to be passed to CMUTIL_LogSystemSet - and passing it there does nothing.
A missing or invalid file is not a failure: a built-in console configuration is installed instead, so logging never breaks a program that was configured badly.
| jsonfile | The path to the JSON configuration file. |
| CMUTIL_LogSystem * CMUTIL_LogSystemGet | ( | void | ) |
Get the current global log system.
| void CMUTIL_LogSystemSet | ( | CMUTIL_LogSystem * | lsys | ) |
Set the global log system.
The log system already installed is destroyed, and ownership of lsys passes to the library. Setting the one that is already installed does nothing, which matters because the configure functions install their own result: passing what one of them returned back to this function would otherwise destroy the live log system.
| lsys | A pointer to the CMUTIL_LogSystem object to set as the global log system. |