Skip to main content

Logging

The logging service was built with customization in mind. In other words, the user can provide their own logging system while initializing the block layer or use the built-in file logger. The default file logger appends log messages from each caller to a shared log file. By default, these files are located at /tmp/SEFLog.<unit>.<domain> where <unit> is an SEF Unit number and <domain> is a QoS Domain ID.

Basic Usage

The supported log levels include the following, in order from most verbose to least: Trace, Debug, Info, Error, Fatal, or no log. By default, each instance is set to log messages at levels Trace and above. The level for logged messages can be changed after initialization.

The level of logging for an already-initialized instance should be accessed only using the public setters and getters, by calling either LogSetLevel() or LogSetLevelByName(). In the case of calling the public setters and getters, the dispatch function to change the log level is called and the local copy of the log level is changed.

To create new log entries, use the following function calls with their respective levels:

LogTrace(LogHandle, ...)
LogDebug(LogHandle, ...)
LogInfo(LogHandle, ...)
LogError(LogHandle, ...)
LogFatal(LogHandle, ...)

The logging macros will not call the log dispatch if the log level is higher than the current level. However, the dispatch function can be called directly to avoid the local level check.

Custom Logger

A custom logger can be used instead of the built-in file logger. In other words, to use a custom log function, the caller should provide a log handle with an iLogger dispatch. While changing the log level or logging, the provided dispatch functions are called in order to update their log level or add a log.

Default File Logger

The default file logger is initialized when the logHandle is not passed in while initializing the SEF Reference FTL. Moreover, an instance of the built-in file logger can be passed in while initializing if a custom log path is needed.

Each line in an output log file holds timestamped information about the level of the logging call (Trace, Debug, Info, Error, or Fatal), the calling function within a source code file and its line number, and the logging message itself.

Log files are not deleted automatically; information from previous calls will persist in log files inside of the /tmp directory (by default) until these files are manually removed and new files generate or are auto-generated.