ether2ser 0.1.0
Ethernet <-> synchronous V.24 bridge firmware for RP2040 + W5500
Loading...
Searching...
No Matches
log.c File Reference
#include <inttypes.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "common.h"
#include "hardware/sync.h"
Include dependency graph for log.c:

Go to the source code of this file.

Data Structures

struct  log_entry_t
 
struct  global_log_state_t
 

Macros

#define LOG_QUEUE_DEPTH   128U
 
#define LOG_QUEUE_MASK   (LOG_QUEUE_DEPTH - 1U)
 
#define LOG_LINE_MAX   160U
 

Functions

static void log_wake_core1 (void)
 
log_level_t get_loglevel (void)
 Get current global log level.
 
void set_loglevel (log_level_t level)
 Set current global log level.
 
void log_write (log_level_t level, const char *fmt,...)
 Emit one formatted log message if level is enabled.
 
void log_core1_drain (void)
 
uint32_t log_take_dropped_count (void)
 
uint32_t log_get_high_water_mark (void)
 
bool log_take_emitted_flag (void)
 Atomically read and clear "log emitted" flag.
 

Variables

static global_log_state_t global_logstate
 

Macro Definition Documentation

◆ LOG_LINE_MAX

#define LOG_LINE_MAX   160U

Definition at line 13 of file log.c.

◆ LOG_QUEUE_DEPTH

#define LOG_QUEUE_DEPTH   128U

Definition at line 11 of file log.c.

◆ LOG_QUEUE_MASK

#define LOG_QUEUE_MASK   (LOG_QUEUE_DEPTH - 1U)

Definition at line 12 of file log.c.

Function Documentation

◆ get_loglevel()

log_level_t get_loglevel ( void  )

Get current global log level.

Returns
Active log level.

Definition at line 61 of file log.c.

References global_log_state_t::current_log_level, and global_logstate.

Referenced by cat_loglevel_get(), cat_loglevel_set(), event_dispatch(), and main().

Here is the caller graph for this function:

◆ log_core1_drain()

void log_core1_drain ( void  )

Definition at line 115 of file log.c.

References global_logstate, global_log_state_t::head, log_entry_t::line, LOG_QUEUE_MASK, global_log_state_t::queue, and global_log_state_t::tail.

Referenced by core1_entry().

Here is the caller graph for this function:

◆ log_get_high_water_mark()

uint32_t log_get_high_water_mark ( void  )

Definition at line 139 of file log.c.

References global_logstate, and global_log_state_t::high_water_mark.

Referenced by update_statistics().

Here is the caller graph for this function:

◆ log_take_dropped_count()

uint32_t log_take_dropped_count ( void  )

Definition at line 132 of file log.c.

References global_log_state_t::dropped, and global_logstate.

Referenced by update_statistics().

Here is the caller graph for this function:

◆ log_take_emitted_flag()

bool log_take_emitted_flag ( void  )

Atomically read and clear "log emitted" flag.

Returns
true if any log was emitted since previous call.

Definition at line 144 of file log.c.

References global_logstate, and global_log_state_t::log_emitted.

Referenced by event_loop().

Here is the caller graph for this function:

◆ log_wake_core1()

static void log_wake_core1 ( void  )
inlinestatic

Definition at line 15 of file log.c.

Referenced by log_write().

Here is the caller graph for this function:

◆ log_write()

void log_write ( log_level_t  level,
const char *  fmt,
  ... 
)

Emit one formatted log message if level is enabled.

Parameters
levelMessage level.
fmtLOG_PLAIN-style format string.
...Format arguments.

Definition at line 71 of file log.c.

References global_log_state_t::current_log_level, global_log_state_t::dropped, global_logstate, global_log_state_t::head, global_log_state_t::high_water_mark, log_entry_t::line, global_log_state_t::log_emitted, LOG_LEVEL_PLAIN, LOG_LINE_MAX, LOG_QUEUE_MASK, log_wake_core1(), global_log_state_t::queue, and global_log_state_t::tail.

Here is the call graph for this function:

◆ set_loglevel()

void set_loglevel ( log_level_t  level)

Set current global log level.

Parameters
levelNew log level.

Definition at line 66 of file log.c.

References global_log_state_t::current_log_level, and global_logstate.

Referenced by cat_loglevel_set(), and init_app().

Here is the caller graph for this function:

Variable Documentation

◆ global_logstate

global_log_state_t global_logstate
static
Initial value:
= {.current_log_level = LOG_LEVEL_INFO,
.head = 0U,
.tail = 0U,
.dropped = 0U,
.high_water_mark = 0U,
.log_emitted = false}
@ LOG_LEVEL_INFO
Definition common.h:90

Definition at line 54 of file log.c.

Referenced by get_loglevel(), log_core1_drain(), log_get_high_water_mark(), log_take_dropped_count(), log_take_emitted_flag(), log_write(), and set_loglevel().