Yder
Logging library written in C
Functions
Initialization and closing functions

Functions

int y_init_logs (const char *app, const unsigned long init_mode, const unsigned long init_level, const char *init_log_file, const char *message)
 
int y_set_logs_callback (void(*y_callback_log_message)(void *cls, const char *app_name, const time_t date, const unsigned long level, const char *message), void *cls, const char *message)
 
int y_set_date_format (const char *format, const char *message)
 
int y_set_split_message_newline (int split, const char *message)
 
int y_close_logs (void)
 

Detailed Description

Function Documentation

◆ y_close_logs()

int y_close_logs ( void  )

Close the logs

Returns
1 on success, 0 on error

◆ y_init_logs()

int y_init_logs ( const char *  app,
const unsigned long  init_mode,
const unsigned long  init_level,
const char *  init_log_file,
const char *  message 
)

Initialize logging with mode and level parameters, specify a log file if needed

Parameters
appthe name of the application that will be included in all log messages
init_modelog mode, values available are Y_LOG_MODE_NONE, Y_LOG_MODE_CONSOLE, Y_LOG_MODE_SYSLOG, Y_LOG_MODE_FILE, Y_LOG_MODE_JOURNALD Multiple log modes are possible, values must be stacked, ex: Y_LOG_MODE_SYSLOG|Y_LOG_MODE_JOURNALD
init_levelminimum level of the log messages Values available are Y_LOG_LEVEL_NONE, Y_LOG_LEVEL_ERROR, Y_LOG_LEVEL_WARNING, Y_LOG_LEVEL_INFO or Y_LOG_LEVEL_DEBUG
init_log_filepath to the file that will contain the log messages if log mode Y_LOG_MODE_FILE is selected
messagefirst message that will be appear in the logs
Returns
1 on success, 0 on error

◆ y_set_date_format()

int y_set_date_format ( const char *  format,
const char *  message 
)

Specify a date format for console and file logging Uses strftime syntax

Parameters
formatdate format using strftime syntax
messagemessage that will be appear in the logs
Returns
1 on success, 0 on error

◆ y_set_logs_callback()

int y_set_logs_callback ( void(*)(void *cls, const char *app_name, const time_t date, const unsigned long level, const char *message)  y_callback_log_message,
void *  cls,
const char *  message 
)

Specify a callback function that will catch all log messages In addition to other logs output already defined in y_init_logs

Parameters
y_callback_log_messagea pointer to a user-defined callback function
clsa user-defined pointer that will be available on y_callback_log_message
messagemessage that will be appear in the logs
Returns
1 on success, 0 on error

◆ y_set_split_message_newline()

int y_set_split_message_newline ( int  split,
const char *  message 
)

Specify if the log messages must be splitted when a newline is in it This function may have incidence on the application speed, because it adds more memory allocations on each log message. I recommend to use it only if relevant

Parameters
split0 to disable splitted logs, 1 to enable
messagemessage that will be appear in the logs
Returns
1 on success, 0 on error