Yder: Initialization and closing functions

Yder Logging library written in C

Loading...
Searching...
No Matches
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

  app | the name of the application that will be included in all log messages
  init_mode | log 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_level | minimum 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_file | path to the file that will contain the log messages if log mode Y_LOG_MODE_FILE is selected
  message | first 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

  format | date format using strftime syntax
  message | message that will be appear in the logs

Returns
  1 on success, 0 on error

## ◆ y_set_logs_callback()

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 )

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_message | a pointer to a user-defined callback function
  cls | a user-defined pointer that will be available on y_callback_log_message
  message | message 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

  split | 0 to disable splitted logs, 1 to enable
  message | message that will be appear in the logs

Returns
  1 on success, 0 on error