Log utility module implementation file. More...
#include "mcl/mcl_config_setup.h"
#include "log_util.h"
#include "mcl/mcl_log_util.h"
#include "file_util.h"
#include "definitions.h"
#include "memory.h"
#include <stdio.h>
Go to the source code of this file.
Macros | |
#define | LOG_UTIL_MCL_SYSLOG "mcl_syslog" |
Functions | |
static void | log_util_default_callback (const zf_log_message *const message, void *user_context) |
E_MCL_ERROR_CODE | mcl_log_util_set_output_level (const int log_level) |
Sets the global output level. The output level is used during runtime check. No logs are written if given log level is less than this output level. More... | |
E_MCL_ERROR_CODE | mcl_log_util_initialize (E_LOG_OUTPUT log_output,...) |
This function initializes logging where output channel is set and configured via variable arguments. More... | |
void | mcl_log_util_finalize (void) |
Performs finalizing operations for logging. More... | |
const char * | mcl_log_util_convert_error_code_to_string (E_MCL_ERROR_CODE error_code) |
This function converts the given error code to its string value. More... | |
Variables | |
FILE * | log_file = NULL |
mcl_log_util_callback_t | user_callback = MCL_NULL |
E_LOG_OUTPUT | log_output_global = E_LOG_OUTPUT_STDERR |
const char * | error_code_strings [MCL_ERROR_CODE_END] |
Log utility module implementation file.
Definition in file log_util.c.
#define LOG_UTIL_MCL_SYSLOG "mcl_syslog" |
Definition at line 28 of file log_util.c.
Referenced by mcl_log_util_initialize().
|
static |
Definition at line 133 of file log_util.c.
References E_LOG_OUTPUT_CALLBACK, E_LOG_OUTPUT_FILE, E_LOG_OUTPUT_STDERR, E_LOG_OUTPUT_SYSLOG, file_util_fflush_without_log(), file_util_fwrite_without_log(), log_file, log_output_global, MCL_NULL, and user_callback.
Referenced by mcl_log_util_initialize().
const char* mcl_log_util_convert_error_code_to_string | ( | E_MCL_ERROR_CODE | error_code | ) |
This function converts the given error code to its string value.
[in] | error_code | Error code to convert to string. |
error_code
is invalid. It should not be freed, because its owner is MCL. Definition at line 250 of file log_util.c.
References DEBUG_ENTRY, DEBUG_LEAVE, error_code_strings, MCL_ERROR, MCL_ERROR_CODE_END, MCL_NULL, and MCL_OK.
void mcl_log_util_finalize | ( | void | ) |
Performs finalizing operations for logging.
syslog
has been initialized, this function must be called in order to close output to syslog
. Definition at line 230 of file log_util.c.
References E_LOG_OUTPUT_CALLBACK, E_LOG_OUTPUT_FILE, E_LOG_OUTPUT_NULL, E_LOG_OUTPUT_SYSLOG, file_util_fclose_without_log(), log_file, log_output_global, MCL_NULL, and user_callback.
E_MCL_ERROR_CODE mcl_log_util_initialize | ( | E_LOG_OUTPUT | log_output, |
... | |||
) |
This function initializes logging where output channel is set and configured via variable arguments.
Output channel and related variable arguments are as following:
log_output
= E_LOG_OUTPUT_FILE, second argument has to be the file name. log_output
= E_LOG_OUTPUT_CALLBACK, second argument is mcl_log_util_callback_t and third argument is void *user_context log_output
= E_LOG_OUTPUT_SYSLOG, no additional argument is required. log_output
= E_LOG_OUTPUT_STDERR, no additional argument is required. After initialization any log messages are printed to the chosen output channel.
[in] | log_output | Selects the desired output channel. |
Definition at line 185 of file log_util.c.
References E_LOG_OUTPUT_CALLBACK, E_LOG_OUTPUT_FILE, E_LOG_OUTPUT_SYSLOG, file_util_fopen_without_log(), log_file, log_output_global, log_util_default_callback(), LOG_UTIL_MCL_SYSLOG, MCL_FILE_CANNOT_BE_OPENED, MCL_INVALID_PARAMETER, MCL_NULL, MCL_OK, and user_callback.
E_MCL_ERROR_CODE mcl_log_util_set_output_level | ( | const int | log_level | ) |
Sets the global output level. The output level is used during runtime check. No logs are written if given log level is less than this output level.
[in] | log_level | The output level to set with. Following log levels can be set.
|
Definition at line 174 of file log_util.c.
References LOG_UTIL_LEVEL_FATAL, LOG_UTIL_LEVEL_NONE, LOG_UTIL_LEVEL_VERBOSE, MCL_INVALID_LOG_LEVEL, and MCL_OK.
const char* error_code_strings[MCL_ERROR_CODE_END] |
Definition at line 35 of file log_util.c.
Referenced by mcl_log_util_convert_error_code_to_string().
FILE* log_file = NULL |
Definition at line 22 of file log_util.c.
Referenced by log_util_default_callback(), mcl_log_util_finalize(), and mcl_log_util_initialize().
E_LOG_OUTPUT log_output_global = E_LOG_OUTPUT_STDERR |
Definition at line 33 of file log_util.c.
Referenced by log_util_default_callback(), mcl_log_util_finalize(), and mcl_log_util_initialize().
mcl_log_util_callback_t user_callback = MCL_NULL |
Definition at line 30 of file log_util.c.
Referenced by log_util_default_callback(), mcl_log_util_finalize(), and mcl_log_util_initialize().