The Log API
When debugging a program, inserting printf statements is quite
common. This is also quite common to finally find the bugs, and remove
the prints. Unfortunately, bugs sometimes reappear and putting back
all prints can be tedious.
In order to avoid this enable/disable/... cycle, DSX offers a “level”
feature for printing APIs. Desired verbosity level is then defined
on software generation, not in the sources.
The verbosity
There are 3 ordered verbosity levels defined. They are inclusive
levels. Setting global verbosity level to:
- NONE implies only print statements marked NONE should be
printed,
- TRACE implies only print statements marked TRACE or
NONE should be printed,
- DEBUG implies only print statements marked TRACE, NONE
or DEBUG should be printed.
Functions
-
void srl_log(verbosity, const char *msg)
Conditionally prints a message.
Parameters: |
- verbosity (A verbosity level) – The minimal required verbosity level needed for
the message to appear
- msg – Message to print
|
-
void srl_log_printf(verbosity, const char *msg, ...)
Conditionally prints a printf-formatted message.
Parameters: |
- verbosity (A verbosity level) – The minimal required verbosity level needed for
the message to appear
- msg – Message format to print
- ... – printf-like positional arguments to msg
|
-
void srl_putc(const char chr)
Unconditionally prints a character to some textual output
backend. This is unsupported
Assertions
-
srl_assert(expr)
Ensures the passed expression evaluates to non-zero. If the
assertion fails, make the program stop.
Parameters: |
- expr – A valid C expression having a value.
|