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
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_backend (SYN_LogOutputFn output_fn, SYN_LogLevel min_level)
Core log initialization implementation function.
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_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_backend

Core log initialization implementation function.

void syn_log_init_backend (
    SYN_LogOutputFn output_fn,
    SYN_LogLevel min_level
) 

Use syn_log_init() macro which supports both: * syn_log_init(min_level) * syn_log_init(output_fn, min_level)

Parameters:

  • output_fn Custom output function pointer (or NULL for default port output).
  • min_level Minimum log level threshold for log emission.

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