Logging constraints are based a notion of a 'level range'. Each logger has a high level and a low level. Any messages with a level within (inclusive) the level range of the logger being evaluated will be logged to the assocated fd.
Logger objects may (optionally) have another logger object (and chain) associated to handle IO errors. If this object is NULL and AW_LOGGER_ERR2SYSLOG or AW_LOGGER_ERR2STDERR are set, then IO error messages will go to syslog and stderr, respectively.
Note: By passing a negative fd and enabling AW_LOGGER_DUP2SYSLOG you get basic syslog logging only (writes are skipped for negative fds with no error generated).
Options are listed in aw_logger_flag_t.
This library is NOT thread safe, however, the aw_log() function IS thread safe.
#include "sys.h"
#include "thread.h"
#include "errors.h"
#include "util.h"
Go to the source code of this file.
Data Structures | |
| struct | aw_logger_params_t |
| struct | aw_logger_struct |
Defines | |
| #define | AW_LOGGER_DEFAULT_FLAGS |
| Macro with the default flags settings to pass to aw_logger_init(). | |
| #define | AW_LOGGER_IS_ROTATING(flags) ( (flags)&(AW_LOGGER_ROTATE_HR | AW_LOGGER_ROTATE_DY | AW_LOGGER_ROTATE_MH) ) |
| Macro to test if doing rotation. | |
Typedefs | |
| typedef aw_logger_struct | aw_logger_t |
Enumerations | |
| enum | aw_logger_flag_t { AW_LOGGER_ENABLED = 0x1, AW_LOGGER_CACHEMSG = 0x2, AW_LOGGER_ERR2SYSLOG = 0x4, AW_LOGGER_ERR2STDERR = 0x8, AW_LOGGER_PREPEND_DATE = 0x10, AW_LOGGER_DUP2SYSLOG = 0x20, AW_LOGGER_DUP2STDERR = 0x40, AW_LOGGER_APPEND_NEWLINE = 0x80, AW_LOGGER_ROTATE_HR = 0x100, AW_LOGGER_ROTATE_DY = 0x200, AW_LOGGER_ROTATE_MH = 0x400, AW_LOGGER_DEDUP = 0x800, AW_LOGGER_NBITS } |
| Bit position indicates capability. More... | |
Functions | |
| int32_t | aw_log (aw_logger_t *logger, int32_t level, const char *fmt,...) __attribute__((format(printf |
| Write a message on an aw_logger_t. | |
| int32_t | aw_logger_clear (aw_logger_t *logger) |
| Free any resources allocated and referenced by logger. | |
| void | aw_logger_disable (aw_logger_t *logger) |
| Unset enable bit, update chain. | |
| void | aw_logger_enable (aw_logger_t *logger) |
| Set enable bit, update chain. | |
| int32_t | aw_logger_init (aw_logger_t *logger, aw_logger_params_t *params) |
| Initialize an aw_logger_t. | |
| int32_t | aw_logger_link (aw_logger_t *logger, aw_logger_t *chain) |
| Link logger into loggin chain, update chain. | |
| void | aw_logger_setflags (aw_logger_t *logger, aw_logger_flag_t new_flags) |
| Overwrite flags, update chain. | |
| void | aw_logger_unlink (aw_logger_t *logger) |
| Unlink logger, update chain. | |
|
|
Value: (\ AW_LOGGER_ENABLED | \ AW_LOGGER_CACHEMSG | \ AW_LOGGER_ERR2SYSLOG | \ AW_LOGGER_ERR2STDERR | \ AW_LOGGER_PREPEND_DATE | \ AW_LOGGER_APPEND_NEWLINE \ )
|
|
|
Macro to test if doing rotation.
|
|
|
|
|
|
Bit position indicates capability.
|
|
||||||||||||||||||||
|
Write a message on an aw_logger_t. aw_log
|
|
|
Free any resources allocated and referenced by logger. aw_logger_clear
|
|
|
Unset enable bit, update chain. aw_logger_disable
|
|
|
Set enable bit, update chain. aw_logger_enable
|
|
||||||||||||
|
Initialize an aw_logger_t. aw_logger_init
|
|
||||||||||||
|
Link logger into loggin chain, update chain. aw_logger_link
|
|
||||||||||||
|
Overwrite flags, update chain. aw_logger_setflags
|
|
|
Unlink logger, update chain. aw_logger_unlink
|