Free Electron
|
The logging system has these concepts:
With this structure logging groups can be flexibly configured without any hardcoded enumerations via defines, enums, or whatever.
A Static Logger object, named feLogger, is intended to be used for most logging. However, most logging calls will actually go through the feLog* macros.
Note that the trailing newline is not automatic.
The group for a basic log message is the MODULE macro, if defined, and is otherwise "default". FE's build system automatically sets MODULE to be the module name (such as "src.platform").
Direct logging incurs minimum overhead and processing, and may be independently #ifdef disabled from normal logging. Direct logging has no group.
Binding can use regular expressions, which is where a lot of the flexibility lies. Here is an example of binding all messages to stdout:
Here is an example of binding all debug messages following a particular naming convention:
Clearing a binding is done with the clear method:
Log objects take the vsprinted message and a map of attributes. File, line number, etc, all come in as attributes.
As with any binding, these can be cleared and reset, but as a default, feLogger is initialized like this in its constructor: