SELKIELogger
1.0.0
|
Classes | |
struct | program_state |
Program state and logging information. More... | |
Functions | |
void | log_error (const program_state *s, const char *format,...) |
Output formatted error message. More... | |
void | log_warning (const program_state *s, const char *format,...) |
Output formatted warning message. More... | |
void | log_info (const program_state *s, const int level, const char *format,...) |
Output formatted information message at a given level. More... | |
FILE * | openSerialNumberedFile (const char *prefix, const char *extension, char **name) |
Open dated, serial numbered file with given prefix and extension. More... | |
void | destroy_program_state (program_state *s) |
Cleanly destroy program state. More... | |
void destroy_program_state | ( | program_state * | s | ) |
Cleanly destroy program state.
Ensure dynamically allocated program_state members are freed.
[in] | s | program_state to be destroyed |
void log_error | ( | const program_state * | s, |
const char * | format, | ||
... | |||
) |
Output formatted error message.
Outputs a provided error message, prepending the current program state and the marker "Error: ".
The error message and any additional arguments are passed to vfprintf in order to support formatted output.
Always outputs to stderr in addition to any configured log file.
Cannot be silenced by runtime configuration.
[in] | s | program_state, used for state and configuration details |
[in] | format | printf compatible format string |
void log_info | ( | const program_state * | s, |
const int | level, | ||
const char * | format, | ||
... | |||
) |
Output formatted information message at a given level.
Outputs a provided message, prepending the current program state and the marker "Info:%d: ", with the level value substituted.
The error message and any additional arguments are passed to vfprintf in order to support formatted output.
The level is compared to the current verbosity to determine if messages are output to stdout, file, or both.
[in] | s | program_state, used for state and configuration details |
[in] | level | Detail/Verbosity level for this message |
[in] | format | printf compatible format string |
void log_warning | ( | const program_state * | s, |
const char * | format, | ||
... | |||
) |
Output formatted warning message.
Outputs a provided warning message, prepending the current program state and the marker "Warning: ".
The error message and any additional arguments are passed to vfprintf in order to support formatted output.
Always outputs to stderr in addition to any configured log file.
Cannot be silenced by runtime configuration.
[in] | s | program_state, used for state and configuration details |
[in] | format | printf compatible format string |
FILE * openSerialNumberedFile | ( | const char * | prefix, |
const char * | extension, | ||
char ** | name | ||
) |
Open dated, serial numbered file with given prefix and extension.
Generates a file name with the form [prefix]YYYYMMDDXX.[extension], where XX is a two digit hexadecimal serial number. Starting from 0, the proposed file name is opened in exclusive create mode ("w+x"). If this fails because the file exists, the serial number is incremented and another attempt to create the file is made until either a) an unused serial number is found or b) the serial number reaches 0xFF.
If no valid file name can be generated, or if any other error is encountered, the function returns NULL.
[in] | prefix | File name prefix (can include a path) |
[in] | extension | File extension |
[out] | name | File name (without extension) used, if successful |