LexLeo 0.0.0-dev+f8e5087-dirty
Technical documentation
Loading...
Searching...
No Matches
logger_default.c File Reference

Private implementation of the logger_default adapter. More...

Include dependency graph for logger_default.c:

Go to the source code of this file.

Functions

logger_default_cfg_t logger_default_default_cfg (void)
 Return the default configuration for the logger_default adapter.
 
logger_default_env_t logger_default_default_env (stream_t *stream, const osal_time_ops_t *time_ops, const osal_mem_ops_t *adapter_mem, const logger_env_t *port_env)
 Build a default environment for the logger_default adapter.
 
static logger_status_t logger_default_write_timestamp (stream_t *stream, const osal_time_ops_t *time_ops)
 Write the logger_default timestamp prefix to the target stream.
 
static logger_status_t logger_default_log (void *backend, const char *message)
 Private log implementation for the logger_default backend.
 
static void logger_default_destroy (void *backend)
 Private destroy implementation for the logger_default backend.
 
logger_status_t logger_default_create_logger (logger_t **out, const logger_default_cfg_t *cfg, const logger_default_env_t *env)
 Create a logger instance backed by the logger_default adapter.
 

Variables

static const logger_vtbl_t DEFAULT_VTBL
 Private backend vtable for logger_default.
 

Detailed Description

This file implements:

  • default configuration and environment helpers,
  • private timestamp writing support,
  • the private backend vtable used to wire logger_default into the logger port,
  • direct construction of a logger_default-backed logger_t.

Definition in file logger_default.c.

Function Documentation

◆ logger_default_create_logger()

logger_status_t logger_default_create_logger ( logger_t **  out,
const logger_default_cfg_t cfg,
const logger_default_env_t env 
)

This function allocates the private logger_default backend, initializes it from the injected configuration and environment, and then wires it into the public logger port through logger_create().

Parameters
[out]outReceives the created logger handle. Must not be NULL.
[in]cfgAdapter configuration. Must not be NULL.
[in]envAdapter environment. Must not be NULL.
Return values
LOGGER_STATUS_OKLogger successfully created.
LOGGER_STATUS_INVALIDOne or more public arguments are invalid.
LOGGER_STATUS_OOMAdapter-backend allocation failed.

Definition at line 314 of file logger_default.c.

◆ logger_default_default_cfg()

logger_default_cfg_t logger_default_default_cfg ( void  )

Return a default configuration for the logger_default adapter.

This helper establishes the default runtime behavior of the adapter.

Returns
A well-formed logger_default_cfg_t.

Definition at line 43 of file logger_default.c.

◆ logger_default_default_env()

logger_default_env_t logger_default_default_env ( stream_t stream,
const osal_time_ops_t time_ops,
const osal_mem_ops_t adapter_mem,
const logger_env_t port_env 
)

This helper packages borrowed runtime dependencies into a logger_default_env_t.

Parameters
[in]streamBorrowed target stream used by the adapter.
[in]time_opsBorrowed time operations used for timestamp generation.
[in]adapter_memBorrowed memory operations used for adapter-backend allocation.
[in]port_envBorrowed logger port environment.
Returns
A well-formed logger_default_env_t aggregating the provided dependencies.

Definition at line 70 of file logger_default.c.

◆ logger_default_destroy()

static void logger_default_destroy ( void *  backend)
static

This function releases the private backend object using the injected adapter-memory operations table.

Parameters
[in]backendPrivate logger_default backend handle. May be NULL.

Definition at line 265 of file logger_default.c.

◆ logger_default_log()

static logger_status_t logger_default_log ( void *  backend,
const char *  message 
)
static

This function writes:

  • a timestamp prefix produced from the injected time service,
  • the provided message,
  • an optional trailing newline depending on backend configuration.
Parameters
[in]backendPrivate logger_default backend handle. Must not be NULL.
[in]messageMessage to log.
Return values
LOGGER_STATUS_OKMessage successfully written.
LOGGER_STATUS_INVALIDmessage == NULL.
LOGGER_STATUS_IO_ERRORA required stream write failed or was partial.

Definition at line 209 of file logger_default.c.

◆ logger_default_write_timestamp()

static logger_status_t logger_default_write_timestamp ( stream_t stream,
const osal_time_ops_t time_ops 
)
static

This helper obtains the current epoch time from the injected time service, converts it to a decomposed UTC+0 timestamp, formats it as text, and writes the resulting prefix to stream.

If the injected time service fails, this helper writes the fallback prefix "[timestamp error] " instead.

Parameters
[in]streamTarget stream receiving the timestamp prefix. Must not be NULL.
[in]time_opsBorrowed time operations used to obtain the current epoch time. Must not be NULL.
Return values
LOGGER_STATUS_OKTimestamp prefix successfully written, or fallback timestamp-error prefix successfully written.
LOGGER_STATUS_IO_ERRORA stream write failed or produced a partial write, or timestamp formatting failed.

Definition at line 111 of file logger_default.c.

Variable Documentation

◆ DEFAULT_VTBL

const logger_vtbl_t DEFAULT_VTBL
static
Initial value:
= {
}
static void logger_default_destroy(void *backend)
Private destroy implementation for the logger_default backend.
static logger_status_t logger_default_log(void *backend, const char *message)
Private log implementation for the logger_default backend.

Definition at line 280 of file logger_default.c.