File syn_log.h¶
Go to the source code of this file
Severity-filtered logging system. More...
#include "../common/syn_compiler.h"#include "../common/syn_defs.h"#include <stdarg.h>#include <stddef.h>
Public Types¶
| Type | Name |
|---|---|
| enum | SYN_LogLevel Log severity levels. |
Public Functions¶
| Type | Name |
|---|---|
| void | syn_log (SYN_LogLevel level, const char * tag, const char * fmt, ...) Core log function (printf-style). |
| SYN_LogLevel | syn_log_get_level (void) Get the current runtime minimum log level. |
| void | syn_log_hexdump (const char * tag, const void * data, size_t len) Hex dump utility — output a buffer as hex + ASCII. |
| void | syn_log_init (SYN_LogLevel min_level) Initialize the logging system. |
| void | syn_log_raw (const char * str) Output a raw string with no formatting or prefix. |
| void | syn_log_set_level (SYN_LogLevel level) Change the runtime minimum log level. |
| void | syn_log_va (SYN_LogLevel level, const char * tag, const char * fmt, va_list args) Core log function (va_list variant). |
Macros¶
| Type | Name |
|---|---|
| define | SYN_LOG_BUF_SIZE 192Size of the log formatting buffer in bytes. |
| define | SYN_LOG_D (tag, fmt, ...) [**syn\_log**](syn__log_8c.md#function-syn_log)(SYN\_LOG\_DEBUG, tag, fmt, ##\_\_VA\_ARGS\_\_)Log at DEBUG level. |
| define | SYN_LOG_E (tag, fmt, ...) [**syn\_log**](syn__log_8c.md#function-syn_log)(SYN\_LOG\_ERROR, tag, fmt, ##\_\_VA\_ARGS\_\_)Log at ERROR level. |
| define | SYN_LOG_F (tag, fmt, ...) [**syn\_log**](syn__log_8c.md#function-syn_log)(SYN\_LOG\_FATAL, tag, fmt, ##\_\_VA\_ARGS\_\_)Log at FATAL level. |
| define | SYN_LOG_I (tag, fmt, ...) [**syn\_log**](syn__log_8c.md#function-syn_log)(SYN\_LOG\_INFO, tag, fmt, ##\_\_VA\_ARGS\_\_)Log at INFO level. |
| define | SYN_LOG_LEVEL SYN\_LOG\_DEBUGCompile-time minimum log level (defaults to SYN_LOG_DEBUG). |
| define | SYN_LOG_T (tag, fmt, ...) [**syn\_log**](syn__log_8c.md#function-syn_log)(SYN\_LOG\_TRACE, tag, fmt, ##\_\_VA\_ARGS\_\_)Log at TRACE level. |
| define | SYN_LOG_TIMESTAMP 1 |
| define | SYN_LOG_W (tag, fmt, ...) [**syn\_log**](syn__log_8c.md#function-syn_log)(SYN\_LOG\_WARN, tag, fmt, ##\_\_VA\_ARGS\_\_)Log at WARN level. |
Detailed Description¶
Provides printf-style logging with severity levels, per-module tags, optional timestamps, and ANSI color output. Logging calls below the compile-time minimum level are stripped entirely (zero overhead).
** **
The user provides an output function at init time (typically wrapping UART transmit). If no init is called, a weak default discards output.
** **
Set SYN_LOG_LEVEL in syn_config.h to the minimum level. Any macro call below that level compiles to ((void)0).
** **
static void my_output(const char *str, size_t len) {
syn_port_uart_transmit(0, (const uint8_t *)str, len, 0);
}
syn_log_init(my_output, SYN_LOG_DEBUG);
#define TAG "main"
SYN_LOG_I(TAG, "System started, version %d.%d", 1, 0);
SYN_LOG_D(TAG, "Free memory: %u bytes", free_mem);
SYN_LOG_E(TAG, "Sensor read failed: %d", status);
Output:
[ 1234] I/main: System started, version 1.0
[ 1235] D/main: Free memory: 8192 bytes
[ 1240] E/main: Sensor read failed: -1
Public Types Documentation¶
enum SYN_LogLevel¶
Log severity levels.
enum SYN_LogLevel {
SYN_LOG_TRACE = 0,
SYN_LOG_DEBUG = 1,
SYN_LOG_INFO = 2,
SYN_LOG_WARN = 3,
SYN_LOG_ERROR = 4,
SYN_LOG_FATAL = 5,
SYN_LOG_NONE = 6
};
Public Functions Documentation¶
function syn_log¶
Core log function (printf-style).
Normally called via the SYN_LOG_* macros rather than directly.
Parameters:
levelSeverity level.tagModule/component name (short string).fmtprintf-style format string....Format arguments.
function syn_log_get_level¶
Get the current runtime minimum log level.
Returns:
Current minimum level.
function syn_log_hexdump¶
Hex dump utility — output a buffer as hex + ASCII.
Parameters:
tagLog tag.dataBuffer to dump.lenNumber of bytes.
function syn_log_init¶
Initialize the logging system.
Set to 1 in syn_config.h to enable ANSI color codes.
Output goes directly to syn_port_serial_write — no callback needed.
Parameters:
min_levelMinimum runtime log level (messages below this are suppressed at runtime). Compile-time level still applies.
function syn_log_raw¶
Output a raw string with no formatting or prefix.
Useful for printing hex dumps, tables, or other pre-formatted data that shouldn't get a timestamp/level prefix.
Parameters:
strNull-terminated string to output.
function syn_log_set_level¶
Change the runtime minimum log level.
Parameters:
levelNew minimum level.
function syn_log_va¶
Core log function (va_list variant).
Parameters:
levelSeverity level.tagModule/component name.fmtprintf-style format string.argsva_list of format arguments.
Macro Definition Documentation¶
define SYN_LOG_BUF_SIZE¶
Size of the log formatting buffer in bytes.
define SYN_LOG_D¶
Log at DEBUG level.
define SYN_LOG_E¶
Log at ERROR level.
define SYN_LOG_F¶
Log at FATAL level.
define SYN_LOG_I¶
Log at INFO level.
define SYN_LOG_LEVEL¶
Compile-time minimum log level (defaults to SYN_LOG_DEBUG).
define SYN_LOG_T¶
Log at TRACE level.
define SYN_LOG_TIMESTAMP¶
Set to 0 in syn_config.h to disable timestamp prefix.
define SYN_LOG_W¶
Log at WARN level.
The documentation for this class was generated from the following file src/syntropic/log/syn_log.h