Nexus Embedded Platform 0.1.0
Statically assembled reusable embedded mechanisms
Loading...
Searching...
No Matches
log.h File Reference

Instance-local synchronous bounded log sink. More...

#include "nexus/core/time.h"

Go to the source code of this file.

Data Structures

struct  nx_log_sink_port_t
 Synchronous caller-injected sink. More...
struct  nx_log_t
 Logger storage belongs to its caller; shared immutable port is copied. More...

Enumerations

enum  nx_log_level_t { NX_LOG_DEBUG = 0 , NX_LOG_INFO , NX_LOG_WARNING , NX_LOG_ERROR }
 Structured severity, with filtering before touching a sink. More...

Functions

nx_result_t nx_log_init (nx_log_t *logger, nx_log_sink_port_t sink, nx_log_level_t minimum)
 Initialize an unused logger before exposing it to tasks.
nx_result_t nx_log_write (nx_log_t *logger, nx_log_level_t level, const void *bytes, size_t length, nx_time_us_t deadline)
 Write caller bytes, with no implicit allocation/formatting.
nx_result_t nx_log_flush (nx_log_t *logger, nx_time_us_t deadline)
 Flush an explicit sink without creating a background worker.
nx_result_t nx_log_stop (nx_log_t *logger)
 Reject new writes and test whether the sink has exited.

Detailed Description

Instance-local synchronous bounded log sink.

Author
Nexus Team

Definition in file log.h.

Enumeration Type Documentation

◆ nx_log_level_t

Structured severity, with filtering before touching a sink.

Enumerator
NX_LOG_DEBUG 
NX_LOG_INFO 
NX_LOG_WARNING 
NX_LOG_ERROR 

Definition at line 15 of file log.h.

Function Documentation

◆ nx_log_flush()

nx_result_t nx_log_flush ( nx_log_t * logger,
nx_time_us_t deadline )

Flush an explicit sink without creating a background worker.

Parameters
[in,out]loggerLive instance
[in]deadlineAbsolute sink deadline
Returns
SUCCESS, BUSY, STATE, UNSUPPORTED or sink error
Note
Same task/privilege/CPU domain as write.

◆ nx_log_init()

nx_result_t nx_log_init ( nx_log_t * logger,
nx_log_sink_port_t sink,
nx_log_level_t minimum )

Initialize an unused logger before exposing it to tasks.

Parameters
[out]loggerUnused caller storage
[in]sinkRequired bounded synchronous sink
[in]minimumMinimum accepted severity
Returns
SUCCESS or INVALID

◆ nx_log_stop()

nx_result_t nx_log_stop ( nx_log_t * logger)

Reject new writes and test whether the sink has exited.

Parameters
[in,out]loggerLive instance; external users must eventually join
Returns
SUCCESS when no sink call is active, BUSY while draining
Note
Task context. A stop caller may retry; no active sink call is forcibly cancelled. Join publishers before reclaiming logger/sink storage.

◆ nx_log_write()

nx_result_t nx_log_write ( nx_log_t * logger,
nx_log_level_t level,
const void * bytes,
size_t length,
nx_time_us_t deadline )

Write caller bytes, with no implicit allocation/formatting.

Parameters
[in,out]loggerLive instance
[in]levelMessage severity
[in]bytesMessage bytes, borrowed only during this call
[in]lengthByte count; zero permits NULL
[in]deadlineAbsolute deadline understood by sink
Returns
SUCCESS for filtered/sent bytes, BUSY for concurrent/recursive writes, STATE after stop, otherwise sink error
Note
Task multi-producer entry with nonblocking serialization. M0/M0+ use CPU-local saved-PRIMASK metadata exclusion and require privileged callers on one CPU. Sink calls run after restoring the incoming mask. This does not make NMI/HardFault or cross-security-domain writers valid. IRQ use is prohibited. Drop/retry policy remains with the external caller.