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

Private implementation of the logger port. More...

Include dependency graph for logger.c:

Go to the source code of this file.

Functions

logger_env_t logger_default_env (const osal_mem_ops_t *mem_ops)
 Build a default logger_env_t from injected memory operations.
 
logger_status_t logger_create (logger_t **out, const logger_vtbl_t *vtbl, void *backend, const logger_env_t *env)
 Create a generic logger handle from adapter-provided backend bindings.
 
void logger_destroy (logger_t **l)
 Destroy a logger handle.
 
logger_status_t logger_log (logger_t *l, const char *message)
 Emit a log message through a logger.
 

Function Documentation

◆ logger_create()

logger_status_t logger_create ( logger_t **  out,
const logger_vtbl_t vtbl,
void *  backend,
const logger_env_t env 
)

This function is intended to be called by logger adapters to construct a public logger_t from:

  • a dispatch table describing backend operations,
  • an adapter-owned backend instance,
  • an injected environment carrying runtime dependencies.

The produced logger handle takes ownership of neither the vtable nor the environment object itself; it only stores the required runtime references. The backend lifetime and destruction semantics are governed by the adapter contract, notably through vtbl->destroy.

Parameters
[out]outReceives the created logger handle. Must not be NULL.
[in]vtblBackend dispatch table. Must not be NULL and must provide non-NULL operations.
[in]backendAdapter-owned backend instance to bind to the logger. May be NULL only if the resulting semantics are explicitly supported by the caller, though normal adapters are expected to provide a valid backend.
[in]envLogger environment carrying injected runtime dependencies. Must not be NULL.
Returns
  • LOGGER_STATUS_OK on success
  • LOGGER_STATUS_INVALID if arguments are invalid
  • LOGGER_STATUS_OOM on allocation failure
Postcondition
On success, *out contains a valid logger handle that must later be destroyed via logger_destroy().

Definition at line 27 of file logger.c.

◆ logger_default_env()

logger_env_t logger_default_env ( const osal_mem_ops_t mem_ops)
Parameters
[in]mem_opsMemory operations to expose through the returned environment.
Returns
A logger_env_t such that ret.mem == mem_ops.
Note
This helper does not allocate and performs no validation. It only packages the provided dependency into a public logger_env_t.

Definition at line 22 of file logger.c.

◆ logger_destroy()

void logger_destroy ( logger_t **  l)
Parameters
[in,out]lAddress of the logger handle to destroy.

If l == NULL or *l == NULL, this function does nothing. Otherwise, it releases the logger object and sets *l to NULL.

Definition at line 57 of file logger.c.

◆ logger_log()

logger_status_t logger_log ( logger_t l,
const char *  message 
)
Parameters
[in]lLogger handle used to emit the message.
[in]messageNull-terminated message to log.
Returns
Operation status.

This function exposes the borrower-facing logging operation of the logger port.

Definition at line 77 of file logger.c.