OS
v1.7.5
Documentation
|
QuarkTS++ includes the qOS::logger class that implements application-level logging. This provides logging APIs based on C++-style streams and various helper macros. You can log a message by simply streaming things to logger::out(<a particular severity level>)
, e.g.. Messages can be simple text or the value of variables in specific base formats.
To use the qOS::logger class, a single-char output function must be defined using the logger::setOutputFcn() function.
A single-char output function should follow this prototype:
The body of this user-defined function should have a hardware-dependent code to print out the c
variable through a specific peripheral.
qOS::logger::out() is the api that should be called every time the end user needs to write an entry to the log
We can configure the output with whatever severity levels we deem appropriate, including : info
, warning
, error
and fatal
. And also the debug
and verbose
can be used to provide additional source-location information.
For tracing memory from a specified target address, you should use the qOS::logger::mem() specifier to define the number of bytes to be visualized of the memory block that should be given after as a pointer.
In the example below, an UART output function is coded to act as the printer. Here, the target MCU is an ARM-Cortex M0 with the UART1 as the selected peripheral for this purpose.
As seen above, the function follows the required prototype. Later, in the main thread, a call to qOS::trace::setOutputFcn() is used to set up the output-function.
After that, trace macros will be available for use.