logging¶
Custom logging utilities, inspired by Python’s logging module.
Note
Under the hood, this is just a wrapper on top of printf().
Default format for logging messages.
-
enum log_level_t¶
[source] Different level of severity. Used to filter out messages.
Warning
If you want to add a new one, it has to be the last element.
Hint
The logging() function will apply an extra transformation to your input, based on a custom format.
Its specifiers being:
%LL: The message’s level (long). Eg:DEBUG.These strings are set in
level_str.
%LS: Print only the first char of the previous string. Eg:D.%M: The actual message created bymsgand...passed tologging(). With its regular format.%T: Current time, you can overridelog_time()to hook it with a RTC or whatever.Default implementation is seconds since boot.
%%: Write a literal%.
For example, with format of [%LL] %T -- %M, messages would look like: [DEBUG] 3s -- Formatted message
-
log_level_t get_logging_level(void)¶
[source] Get the current level. Messages with a lower severity are dropped.
-
void set_logging_level(log_level_t level)¶
[source] Change the current level.
-
void step_logging_level(bool increase)¶
[source] Increase (or decrease) by one the level.
The direction is based on
increase.
Attention
From this point, the functions are mostly implementation details.
You, most likely, don’t need to know anything about them.
-
log_level_t get_current_message_level(void)¶
[source] Get the severity of the message being emitted.
This may be used by a
sendchar_func_tinternally.