Embedded Multicore Building Blocks V1.0.0
Typedefs | Enumerations | Functions
Logging

Simple logging facilities. More...

Typedefs

typedef void(* embb_log_function_t) (void *context, char const *message)
 Logging function type. More...
 

Enumerations

enum  embb_log_level_t {
  EMBB_LOG_LEVEL_NONE, EMBB_LOG_LEVEL_ERROR, EMBB_LOG_LEVEL_WARNING, EMBB_LOG_LEVEL_INFO,
  EMBB_LOG_LEVEL_TRACE
}
 Log levels available for filtering the log. More...
 

Functions

void embb_log_write_file (void *context, char const *message)
 Default logging function. More...
 
void embb_log_set_log_level (embb_log_level_t log_level)
 Sets the global log level. More...
 
void embb_log_set_log_function (void *context, embb_log_function_t func)
 Sets the global logging function. More...
 
void embb_log_write (char const *channel, embb_log_level_t log_level, char const *message,...)
 Logs a message to the given channel with the specified log level. More...
 
void embb_log_trace (char const *channel, char const *message,...)
 Logs a message to the given channel with EMBB_LOG_LEVEL_TRACE using embb_log_write(). More...
 
void embb_log_info (char const *channel, char const *message,...)
 Logs a message to the given channel with EMBB_LOG_LEVEL_INFO using embb_log_write(). More...
 
void embb_log_warning (char const *channel, char const *message,...)
 Logs a message to the given channel with EMBB_LOG_LEVEL_WARNING using embb_log_write(). More...
 
void embb_log_error (char const *channel, char const *message,...)
 Logs a message to the given channel with EMBB_LOG_LEVEL_ERROR using embb_log_write(). More...
 

Detailed Description

Simple logging facilities.

Typedef Documentation

typedef void(* embb_log_function_t) (void *context, char const *message)

Logging function type.

This function is used by embb_log_write() to transfer a log message to its desired destination. The user may specify a pointer to a context that contains additional data (filter rules, file handles etc.) needed to put the message where it should go. This pointer might be NULL if no additional data is needed.

Concurrency
Thread-safe

Enumeration Type Documentation

Log levels available for filtering the log.

Enumerator
EMBB_LOG_LEVEL_NONE 

show no log messages

EMBB_LOG_LEVEL_ERROR 

show errors only

EMBB_LOG_LEVEL_WARNING 

show warnings and errors

EMBB_LOG_LEVEL_INFO 

show info, warnings, and errors

EMBB_LOG_LEVEL_TRACE 

show everything

Function Documentation

void embb_log_write_file ( void *  context,
char const *  message 
)

Default logging function.

Writes to the given file (context needs to be a FILE*).

Precondition
context is not NULL.
Concurrency
Thread-safe
Parameters
[in]contextUser data, in this case a FILE* file handle.
[in]messageThe message to write
void embb_log_set_log_level ( embb_log_level_t  log_level)

Sets the global log level.

This determines what messages will be shown, messages with a more detailed log level will be filtered out. The default log level is EMBB_LOG_LEVEL_NONE.

Concurrency
Not thread-safe
Parameters
[in]log_levelLog level to use for filtering
void embb_log_set_log_function ( void *  context,
embb_log_function_t  func 
)

Sets the global logging function.

The logging function implements the mechanism for transferring log messages to their destination. context is a pointer to data the user needs in the function to determine where the messages should go (may be NULL if no additional data is needed). The default logging function is embb_log_write_file() with context set to stdout.

See also
embb_log_function_t
Concurrency
Not thread-safe
Parameters
[in]contextUser context to supply as the first parameter of the logging function
[in]funcThe logging function
void embb_log_write ( char const *  channel,
embb_log_level_t  log_level,
char const *  message,
  ... 
)

Logs a message to the given channel with the specified log level.

If the log level is greater than the configured log level for the channel, the message will be ignored.

See also
embb_log_set_log_level, embb_log_set_log_function
Concurrency
Thread-safe
Parameters
[in]channelUser specified channel id for filtering the log later on. Might be NULL, channel identifier will be "global" in that case
[in]log_levelLog level to use
[in]messageMessage to convey, may use printf style formatting
void embb_log_trace ( char const *  channel,
char const *  message,
  ... 
)

Logs a message to the given channel with EMBB_LOG_LEVEL_TRACE using embb_log_write().

In non-debug builds, this function does nothing.

See also
embb_log_write
Concurrency
Thread-safe
Parameters
[in]channelUser specified channel id
[in]messageMessage to convey, may use printf style formatting
void embb_log_info ( char const *  channel,
char const *  message,
  ... 
)

Logs a message to the given channel with EMBB_LOG_LEVEL_INFO using embb_log_write().

In non-debug builds, this function does nothing.

See also
embb_log_write
Concurrency
Thread-safe
Parameters
[in]channelUser specified channel id
[in]messageMessage to convey, may use printf style formatting
void embb_log_warning ( char const *  channel,
char const *  message,
  ... 
)

Logs a message to the given channel with EMBB_LOG_LEVEL_WARNING using embb_log_write().

See also
embb_log_write
Concurrency
Thread-safe
Parameters
[in]channelUser specified channel id
[in]messageMessage to convey, may use printf style formatting
void embb_log_error ( char const *  channel,
char const *  message,
  ... 
)

Logs a message to the given channel with EMBB_LOG_LEVEL_ERROR using embb_log_write().

See also
embb_log_write
Concurrency
Thread-safe
Parameters
[in]channelUser specified channel id
[in]messageMessage to convey, may use printf style formatting