Skip to content

File syn_log.c

FileList > log > syn_log.c

Go to the source code of this file

Logging system implementation.

  • #include "../port/syn_port_serial.h"
  • #include "../port/syn_port_system.h"
  • #include "../util/syn_assert.h"
  • #include "../util/syn_fmt.h"
  • #include "syn_log.h"
  • #include <stdio.h>
  • #include <string.h>

Public Static Attributes

Type Name
bool s_inited = false
SYN_LogLevel s_level = SYN\_LOG\_DEBUG
const char *const s_level_chars = "TDIWEF"
Single-char level labels: T=Trace, D=Debug, I=Info, W=Warn, E=Error, F=Fatal.
const char *const s_level_colors = /* multi line expression */

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 LOG_COLOR_RESET "\033[0m"

Public Static Attributes Documentation

variable s_inited

bool s_inited;

Init flag.


variable s_level

SYN_LogLevel s_level;

Current minimum log level.


variable s_level_chars

Single-char level labels: T=Trace, D=Debug, I=Info, W=Warn, E=Error, F=Fatal.

const char* const s_level_chars;


variable s_level_colors

const char* const s_level_colors[];

Public Functions Documentation

function syn_log

Core log function (printf-style).

void syn_log (
    SYN_LogLevel level,
    const char * tag,
    const char * fmt,
    ...
) 

Normally called via the SYN_LOG_* macros rather than directly.

Parameters:

  • level Severity level.
  • tag Module/component name (short string).
  • fmt printf-style format string.
  • ... Format arguments.

function syn_log_get_level

Get the current runtime minimum log level.

SYN_LogLevel syn_log_get_level (
    void
) 

Returns:

Current minimum level.


function syn_log_hexdump

Hex dump utility — output a buffer as hex + ASCII.

void syn_log_hexdump (
    const char * tag,
    const void * data,
    size_t len
) 

Parameters:

  • tag Log tag.
  • data Buffer to dump.
  • len Number of bytes.

function syn_log_init

Initialize the logging system.

void syn_log_init (
    SYN_LogLevel min_level
) 

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_level Minimum 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.

void syn_log_raw (
    const char * str
) 

Useful for printing hex dumps, tables, or other pre-formatted data that shouldn't get a timestamp/level prefix.

Parameters:

  • str Null-terminated string to output.

function syn_log_set_level

Change the runtime minimum log level.

void syn_log_set_level (
    SYN_LogLevel level
) 

Parameters:

  • level New minimum level.

function syn_log_va

Core log function (va_list variant).

void syn_log_va (
    SYN_LogLevel level,
    const char * tag,
    const char * fmt,
    va_list args
) 

Parameters:

  • level Severity level.
  • tag Module/component name.
  • fmt printf-style format string.
  • args va_list of format arguments.

Macro Definition Documentation

define LOG_COLOR_RESET

#define LOG_COLOR_RESET `"\033[0m"`


The documentation for this class was generated from the following file src/syntropic/log/syn_log.c