Haka: include/haka/log.h File Reference

Haka

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Macros | Typedefs | Enumerations | Functions
log.h File Reference
`#include <haka/types.h>`
`#include <haka/compiler.h>`
`#include <haka/container/list.h>`

Go to the source code of this file.

## Data Structures
struct | logger

## Macros
#define | INVALID_SECTION_ID -1
#define | LOG_FATAL(section, fmt, ...) LOG(HAKA_LOG_FATAL, section, fmt, ##__VA_ARGS__)

## Typedefs
typedef int | section_id

## Enumerations

## Functions
const char * | level_to_str (log_level level)
log_level | str_to_level (const char *str)
section_id | register_log_section (const char *name)
section_id | search_log_section (const char *name)
bool | check_section_log_level (section_id section, log_level level)
bool | setlevel (log_level level, const char *name)
log_level | getlevel (const char *name)
void | enable_stdout_logging (bool enable)
bool | stdout_message (log_level lvl, const char *module, const char *message)
bool | add_logger (struct logger *logger)
bool | remove_logger (struct logger *logger)
void | remove_all_logger ()

## Detailed Description

Logging API.

## Macro Definition Documentation

#define INVALID_SECTION_ID -1

Invalid section id.

#define LOG_FATAL | ( |  | section,
|  |  | fmt,
|  |  | ...
| ) |  | LOG(HAKA_LOG_FATAL, section, fmt, ##__VA_ARGS__)

Log a message with string formating in various level.

## Typedef Documentation

typedef int section_id

Log section identifier.

## Enumeration Type Documentation

anonymous enum

Global section id.

enum log_level

Log level.

Enumerator
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.

## Function Documentation

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 check_section_log_level | ( | section_id | section,
|  | log_level | level
| ) |  |

Check if section should be logged.

void enable_stdout_logging | ( | bool | enable | ) |

Change the display of log message on stdout.

log_level getlevel | ( | const char * | name | ) |

Get the logging level for a given section name.

const char* level_to_str | ( | log_level | level | ) |

Convert a logging level to a human readable string.

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

section_id register_log_section | ( | const char * | name | ) |

Register a log section.

void remove_all_logger | ( |  | ) |

Remove all loggers.

bool remove_logger | ( | struct logger * | logger | ) |

Remove a logger.

section_id search_log_section | ( | const char * | name | ) |

Search for a log section by name.

Returns
  The section id or INVALID_SECTION_ID if not found.

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.

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

Show a log line on the stdout.

log_level str_to_level | ( | const char * | str | ) |

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