Logging#
libaes70 contains simple printf-style macro for emitting log messages. The default
implementation emits these messages to stderr using fprintf. This default
implementation can be replaced by defining the macro AES70_PRINTF before including
library headers. See examples/custom_logging for an
example.
The library defines these logging levels:
| Name | Level |
|---|---|
| ERROR | 1 |
| WARNING | 2 |
| INFO | 3 |
| TRACE | 4 |
Logging can be enabled by setting the preprocessor symbol AES70_LOG_LEVEL, e.g. passing
-DAES70_LOG_LEVEL=2 would enable both ERROR and WARNING levels.
Usage#
Log messages can be generated using the macros
AES70_LOG_ERROR(fmt, ...)AES70_LOG_WARNING(fmt, ...)AES70_LOG_INFO(fmt, ...)AES70_LOG_TRACE(fmt, ...)
If the corresponding logging level is enabled, the following defines are set.
AES70_LOG_ERROR_ENABLEDAES70_LOG_WARNING_ENABLEDAES70_LOG_INFO_ENABLEDAES70_LOG_TRACE_ENABLED
Interpretation#
The above log levels can be interpreted a follows:
-
ERROR: These events should not occur in a production system. This can mean that there are bugs or that an API has been used incorrectly. -
WARNING: These events should not occur in a production system under normal operation. However, these warnings may happen in situations in which e.g. another network endpoint misbehaves. These messages are helpful during development. -
INFO: These events will regularly occur in a production system. They can help understand what happens under the hood and may be helpful during development and testing. -
TRACE: These events occur all the time. They can be useful when debugging problems in order to help understand under which circumstances a given problem occurs.
What log level to use#
If the overhead of having logging enabled is acceptable for production builds, it is recommended to
run with either ERROR or WARNING. WARNING messages can be triggered by misbehaving clients, so
it could be useful when investigating system instabilities later.
INFO and TRACE are only recommended for development builds or during testing.