Babeltrace 2 C API  2.0.0
Open-source trace manipulation framework
Typedefs | Enumerations | Functions
Logging

Detailed Description

Logging level enumerators and library logging control.

The logging API offers logging level enumerators (bt_logging_level) as well as functions to control libbabeltrace2's internal logging.

Note
This API does not offer macros and functions to write logging statements: as of Babeltrace 2.0, the actual mechanism to log is implementation-defined for each user plugin.

libbabeltrace2 contains many hundreds of logging statements to help you follow and debug your plugin or program.

The library's initial logging level is controlled by the LIBBABELTRACE2_INIT_LOG_LEVEL environment variable. If this environment variable is not set at library load time, the library's initial logging level is BT_LOGGING_LEVEL_NONE. See Logging to learn more.

Set libbabeltrace2's current logging level with bt_logging_set_global_level().

bt_logging_set_global_level() only controls libbabeltrace2's logging level; it does not control the logging level of:

As of Babeltrace 2.0, there's no module-specific logging level control: bt_logging_set_global_level() sets the logging level of all the library's modules.

libbabeltrace2 writes its logging statements to the standard error stream. A logging line looks like this:

05-11 00:58:03.691 23402 23402 D VALUES bt_value_destroy@values.c:498 Destroying value: addr=0xb9c3eb0

See Logging to learn more about the logging statement line's format.

You can set a minimal logging level at the Babeltrace 2 project's build time (see Logging to learn how). The logging statements with a level that's less severe than the minimal logging level are not built. For example, if the minimal logging level is BT_LOGGING_LEVEL_INFO, the BT_LOGGING_LEVEL_TRACE and BT_LOGGING_LEVEL_DEBUG logging statements are not built. Use bt_logging_get_minimal_level() to get the library's minimal logging level.

Typedefs

typedef enum bt_logging_level bt_logging_level
 Logging level enumerators.
 

Enumerations

enum  bt_logging_level {
  BT_LOGGING_LEVEL_TRACE,
  BT_LOGGING_LEVEL_DEBUG,
  BT_LOGGING_LEVEL_INFO,
  BT_LOGGING_LEVEL_WARNING,
  BT_LOGGING_LEVEL_ERROR,
  BT_LOGGING_LEVEL_FATAL,
  BT_LOGGING_LEVEL_NONE
}
 Logging level enumerators. More...
 

Functions

void bt_logging_set_global_level (bt_logging_level logging_level)
 Sets the logging level of all the libbabeltrace2 modules to logging_level. More...
 
bt_logging_level bt_logging_get_global_level (void)
 Returns the current logging level of all the libbabeltrace2 modules. More...
 
bt_logging_level bt_logging_get_minimal_level (void)
 Returns the library's minimal (build-time) logging level. More...
 

Enumeration Type Documentation

◆ bt_logging_level

Logging level enumerators.

Enumerator
BT_LOGGING_LEVEL_TRACE 

TRACE level.

Low-level debugging context information.

The TRACE logging statements can significantly impact performance.

BT_LOGGING_LEVEL_DEBUG 

DEBUG level.

Debugging information, with a higher level of details than the TRACE level.

The DEBUG logging statements do not significantly impact performance.

BT_LOGGING_LEVEL_INFO 

INFO level.

Informational messages that highlight progress or important states of the application, plugins, or library.

The INFO logging statements do not significantly impact performance.

BT_LOGGING_LEVEL_WARNING 

WARNING level.

Unexpected situations which still allow the execution to continue.

The WARNING logging statements do not significantly impact performance.

BT_LOGGING_LEVEL_ERROR 

ERROR level.

Errors that might still allow the execution to continue.

Usually, once one or more errors are reported at this level, the application, plugin, or library won't perform any more useful task, but it should still exit cleanly.

The ERROR logging statements do not significantly impact performance.

BT_LOGGING_LEVEL_FATAL 

FATAL level.

Severe errors that lead the execution to abort immediately.

The FATAL logging statements do not significantly impact performance.

BT_LOGGING_LEVEL_NONE 

Logging is disabled.

Function Documentation

◆ bt_logging_set_global_level()

void bt_logging_set_global_level ( bt_logging_level  logging_level)

Sets the logging level of all the libbabeltrace2 modules to logging_level.

The library's global logging level does not affect the logging level of individual components and query operations.

Parameters
[in]logging_levelNew library's global logging level.
See also
bt_logging_get_global_level() — Returns the current library's global logging level.

◆ bt_logging_get_global_level()

bt_logging_level bt_logging_get_global_level ( void  )

Returns the current logging level of all the libbabeltrace2 modules.

Returns
Library's current global logging level.
See also
bt_logging_set_global_level() — Sets the current library's global logging level.

◆ bt_logging_get_minimal_level()

bt_logging_level bt_logging_get_minimal_level ( void  )

Returns the library's minimal (build-time) logging level.

The library logging statements with a level that's less severe than the minimal logging level are not built.

For example, if the minimal logging level is BT_LOGGING_LEVEL_INFO, the BT_LOGGING_LEVEL_TRACE and BT_LOGGING_LEVEL_DEBUG logging statements are not built.

Returns
Library's minimal logging level.
See also
bt_logging_get_global_level() — Returns the current library's global logging level.