Previous topic

Logger

Next topic

Containers

s_logger StructureΒΆ

typedef struct s_logger

The s_logger structure definition.

The logger consists of private data which can be anything required by the specific implementation, as it is only defined as an opaque type. The different logger implementations must implement the function pointers as described. If any error occurs during one of the logger functions, the logger must try and continue and print the error to stderr.

Public Members
s_logger_private_info *data

Logger private data.

Defined by each logger as required (opaque type).

s_erc (*v_write)(const s_logger *self, s_log_event level, const char *error_msg, const char *func_name, const char *file_name, int line_num, const char *user_msg, va_list argp)

Format and write the given logging event information to the logger.

Must be implemented by each logger as it is called by s_logger_vwrite and s_logger_write. If the message cannot be formatted or written successfully then the calling function (s_logger_vwrite or s_logger_write) will attemp to write the message to stdout.

Parameters:
  • self

    This logger object.

  • level

    The event level.

  • error_msg

    As defined by s_erc.

  • func_name

    Calling function name.

  • file_name

    Calling function file name.

  • line_num

    Calling line number in function.

  • user_msg

    A format string specifying the string to write and the format of the arguments in the va_list.

  • argp

    The va_list, see the standard function vprintf(). The value of argp is undefined after the call to this function.

Return:

Error code.

s_erc (*destroy)(s_logger *self)

Destroy the logger object’s associated resources.

The logger’s memory itself must not be freed. Must be implemented by each logger as it is called by s_logger_destroy.

Parameters:
  • logger

    This logger object.

Return:

Error code.