SafeAPI Backend POSIX
POSIX/Linux OAL backend for safeAPIFreamwork
Loading...
Searching...
No Matches
sapi_posix_backend_log.c File Reference

POSIX sapi_log backend: non-blocking best-effort write to stderr (ADR-018 section 2.3), matching REQ-OAL-LOG-001 ("best-effort, non-blocking, must never affect caller control flow"). More...

#include "safeapi/posix_backend/sapi_posix_backend.h"
#include <stdio.h>
Include dependency graph for sapi_posix_backend_log.c:

Go to the source code of this file.

Functions

static const char * level_to_prefix (sapi_log_level_t level)
static sapi_status_t backend_init (void)
static void backend_write (sapi_log_level_t level, const char *tag, const char *message)
const sapi_log_backend_t * sapi_posix_backend_log (void)
 The POSIX sapi_log backend (non-blocking write to stderr).

Variables

static const sapi_log_backend_t s_posix_log_backend = { backend_init, backend_write }

Detailed Description

POSIX sapi_log backend: non-blocking best-effort write to stderr (ADR-018 section 2.3), matching REQ-OAL-LOG-001 ("best-effort, non-blocking, must never affect caller control flow").

Known simplification (stated in ADR-018): no queue, no separate drain thread - a direct fwrite() to stderr. stderr writes are typically fast enough in practice not to violate the non-blocking intent for a first cut, but a deployment wanting a hard non-blocking guarantee (stderr could be a slow pipe/tty under adversarial conditions) should route through a lock-free ring buffer drained by a dedicated low-priority thread instead. write() failures are silently ignored, per REQ-OAL-LOG-001 - logging must never affect caller control flow, so there is nothing meaningful to report back to the caller here.

Definition in file sapi_posix_backend_log.c.

Function Documentation

◆ backend_init()

sapi_status_t backend_init ( void )
static

Definition at line 70 of file sapi_posix_backend_log.c.

◆ backend_write()

void backend_write ( sapi_log_level_t level,
const char * tag,
const char * message )
static

Definition at line 75 of file sapi_posix_backend_log.c.

◆ level_to_prefix()

const char * level_to_prefix ( sapi_log_level_t level)
static

Local makros Local types declarations Local function declarations

Definition at line 45 of file sapi_posix_backend_log.c.

◆ sapi_posix_backend_log()

const sapi_log_backend_t * sapi_posix_backend_log ( void )

The POSIX sapi_log backend (non-blocking write to stderr).

Global variables declarations Global functions

Definition at line 37 of file sapi_posix_backend_log.c.

Variable Documentation

◆ s_posix_log_backend

const sapi_log_backend_t s_posix_log_backend = { backend_init, backend_write }
static

Local variables declarations

Definition at line 31 of file sapi_posix_backend_log.c.