The Logging Subsystem.
The logging system is made up of two parts. The upper layer provides message formatting, and discards log messages that are less than the current log level.
The bottom layer is the logging transport. This can be
- Via LOG messages using the vendor class USB device.
- Over a CDC class USB device (serial console)
The low level implementation is determined by the callback function passed to SysLog_Initialize (or via PIPELINE_LOG_WRITE).
To log messages to the console, use SysLog_Message() and SysLog_Print(). This should not be called within interrupt context.
|
file | syslog.h |
| The upper layer of the Logging subsystem.
|
|
file | usb_console.h |
| A logging transport that uses a USB serial console.
|
|
typedef void(* SysLogWriteFn)(const char *) |
A function pointer to log a message.
- Parameters
-
msg | The message to log, must be NULL terminated. |
The system log levels.
Enumerator |
---|
SYSLOG_DEBUG |
Debug messages.
|
SYSLOG_INFO |
Info messages.
|
SYSLOG_WARN |
Warnings.
|
SYSLOG_ERROR |
Errors.
|
SYSLOG_FATAL |
Fatal events.
|
SYSLOG_ALWAYS |
Always logged regardless of log level.
|
Return the current log level.
- Returns
- The current log level.
Initialize the System Logging module.
- Parameters
-
write_fn | The function to use for logging messages. |
If PIPELINE_LOG_WRITE is defined in app_pipeline.h, the macro will override the write_fn argument.
Return the string description of a log level.
- Parameters
-
- Returns
- A statically allocated string which contains the text description of the log level.
void SysLog_Message |
( |
SysLogLevel |
level, |
|
|
const char * |
msg |
|
) |
| |
Log a message.
- Parameters
-
level | the log level of the message |
msg | the message to log. |
- Note
- This should not be called within interrupt context.
void SysLog_Print |
( |
SysLogLevel |
level, |
|
|
const char * |
format, |
|
|
|
... |
|
) |
| |
Format and log a message.
- Parameters
-
level | the log level of the message |
format | The format string. |
- Note
- This should not be called within interrupt context.
Set the log level.
- Parameters
-
void USBConsole_Log |
( |
const char * |
message | ) |
|
Write a message to the console.
- Parameters
-
message | a NULL terminated string. |
We may not buffer the entire message if the log buffer is full. Since the messages are sent over a serial console, the NULL characters are replaced with
characters.