3.4. LogΒΆ

Logging API.

Defines

HAKA_LOG_LEVEL_MAX

INVALID_SECTION_ID

Invalid section id.

DECLARE_LOG_SECTION(name)

REGISTER_LOG_SECTION(name)

LOG_SECTION(name)

SHOULD_LOG(level, section)

LOG(level, section, fmt, ...)

LOG_FATAL(section, fmt, ...)

Log a message with string formating in various level.

LOG_ERROR(section, fmt, ...)

LOG_WARNING(section, fmt, ...)

LOG_INFO(section, fmt, ...)

LOG_DEBUG(section, fmt, ...)

SHOULD_LOG_FATAL(section)

SHOULD_LOG_ERROR(section)

SHOULD_LOG_WARNING(section)

SHOULD_LOG_INFO(section)

SHOULD_LOG_DEBUG(section)

LOG_TRACE(section, fmt, ...)

SHOULD_LOG_TRACE(section)

Typedefs

typedef int section_id

Log section identifier.

Enums

log_level enum

Log level.

Values:

  • HAKA_LOG_FATAL -

    Fatal errors.

  • HAKA_LOG_ERROR -

    Errors.

  • HAKA_LOG_WARNING -

    Warning.

  • HAKA_LOG_INFO -

    Informations.

  • HAKA_LOG_DEBUG -

    Debugging informations.

  • HAKA_LOG_TRACE -

    Trace debugging (only available in debug build).

  • HAKA_LOG_DEFAULT -

    Reset module log level to global one.

  • HAKA_LOG_LEVEL_LAST -

    Last log level. For internal use only.

Anonymous enum

Global section id.

Values:

  • LOG_SECTION = (core) -
  • LOG_SECTION = (core) -
  • LOG_SECTION = (core) -
  • LOG_SECTION = (core) -
  • LOG_SECTION = (core) -
  • LOG_SECTION = (core) -
Functions

const char * level_to_str(log_level level)

Convert a logging level to a human readable string.

Return
A string representing the logging level. This string is constant and should not be freed.

log_level str_to_level(const char * str)

Convert a logging level represented by a string to the matching enum value.

section_id register_log_section(const char * name)

Register a log section.

section_id search_log_section(const char * name)

Search for a log section by name.

Return
The section id or INVALID_SECTION_ID if not found.

bool check_section_log_level(section_id section, log_level level)

Check if section should be logged.

void _messagef(log_level level, section_id section, const char * fmt, ...)

bool setlevel(log_level level, const char * name)

Set the logging level to display for a given section name. The name parameter can be NULL in which case it will set the default level.

log_level getlevel(const char * name)

Get the logging level for a given section name.

void enable_stdout_logging(bool enable)

Change the display of log message on stdout.

bool stdout_message(log_level lvl, const char * module, const char * message)

Show a log line on the stdout.

bool add_logger(struct logger * logger)

Add a new logger instance in the logger list. Each logger will receive all logging messages that are emitted by the code.

bool remove_logger(struct logger * logger)

Remove a logger.

void remove_all_logger()

Remove all loggers.

class logger

Logger instance structure.

Public Members

struct list list

void(* destroy)(struct logger *state)

int(* message)(struct logger *state, log_level level, const char *module, const char *message)

Private Members

bool mark_for_remove