SafeAPI RBC 2oo2 Generic Application
IL/CTC route and train logic for the safeAPIRBC2oo2 reference RBC
Loading...
Searching...
No Matches
gateway_c_logctl.c File Reference

See gateway_c_logctl.h. More...

#include "gateway_c_logctl.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "safeapi/oal/log/sapi_log.h"
#include "common/rbc_wire_types.h"
#include "common/site_config.h"
#include "gateway_c_il_handler.h"
Include dependency graph for gateway_c_logctl.c:

Go to the source code of this file.

Macros

#define GATEWAY_C_LOGCTL_LINE_MAX   16U

Functions

static bool gateway_c_logctl_read_level (const char *path, sapi_log_level_t *out_level)
void gateway_c_logctl_poll (gateway_c_context_t *ctx)
 Called once per C cycle (gateway_c_execute()). If SAPI_RBC_LOG_LEVEL_FILE is set and its first line now names a different valid level than last applied, apply it to this process (sapi_log_set_level()) and broadcast a RBC_MSG_SET_LOG_LEVEL frame to A and B (gateway_c_il_handler_broadcast_to_ab()). No-op otherwise - including when the env var is unset, the file is missing, or the content is unchanged/invalid.

Variables

static int s_applied_level = -1

Detailed Description

See gateway_c_logctl.h.

Definition in file gateway_c_logctl.c.

Macro Definition Documentation

◆ GATEWAY_C_LOGCTL_LINE_MAX

#define GATEWAY_C_LOGCTL_LINE_MAX   16U

Local makros Longest level spelling ("WARNING") + a bit of slack for a trailing newline / stray whitespace on the file's first line.

Definition at line 20 of file gateway_c_logctl.c.

Function Documentation

◆ gateway_c_logctl_poll()

void gateway_c_logctl_poll ( gateway_c_context_t * ctx)

Called once per C cycle (gateway_c_execute()). If SAPI_RBC_LOG_LEVEL_FILE is set and its first line now names a different valid level than last applied, apply it to this process (sapi_log_set_level()) and broadcast a RBC_MSG_SET_LOG_LEVEL frame to A and B (gateway_c_il_handler_broadcast_to_ab()). No-op otherwise - including when the env var is unset, the file is missing, or the content is unchanged/invalid.

Global functions

Parameters
ctxGateway context (for the site name in log lines). Must not be NULL.

Definition at line 33 of file gateway_c_logctl.c.

◆ gateway_c_logctl_read_level()

bool gateway_c_logctl_read_level ( const char * path,
sapi_log_level_t * out_level )
static

Local function declarations

Definition at line 68 of file gateway_c_logctl.c.

Variable Documentation

◆ s_applied_level

int s_applied_level = -1
static

Local variables declarations Last level actually applied by this module, so an unchanged file is a no-op. Starts at an out-of-range sentinel so the first valid read always "changes".

Definition at line 26 of file gateway_c_logctl.c.