BSL v0.0.0 - 0.geda3e66
AMMOS Bundle Protocol Security Library (BSL)
|
Implementation of event logging using stderr
output stream.
More...
#include <pthread.h>
#include <stdarg.h>
#include <stdio.h>
#include <strings.h>
#include <sys/time.h>
#include <time.h>
#include <BPSecLib_Private.h>
#include <BSLConfig.h>
#include <m-buffer.h>
#include <m-string.h>
#include <m-atomic.h>
Data Structures | |
struct | BSL_LogEvent_event_t |
A single event for the log. More... | |
Macros | |
#define | BSL_LOG_QUEUE_SIZE 100 |
Number of events to buffer to I/O thread. | |
#define | M_OPL_BSL_LogEvent_event_t() |
OPLIST for BSL_LogEvent_event_t. | |
Functions | |
static void | BSL_LogEvent_event_init (BSL_LogEvent_event_t *obj) |
static void | BSL_LogEvent_event_deinit (BSL_LogEvent_event_t *obj) |
static void | BSL_LogEvent_event_init_set (BSL_LogEvent_event_t *obj, const BSL_LogEvent_event_t *src) |
static void | BSL_LogEvent_event_init_move (BSL_LogEvent_event_t *obj, BSL_LogEvent_event_t *src) |
static void | BSL_LogEvent_event_set (BSL_LogEvent_event_t *obj, const BSL_LogEvent_event_t *src) |
uint8_t * | BSL_Log_DumpAsHexString (uint8_t *dstbuf, size_t dstlen, const uint8_t *srcbuf, size_t srclen) |
Helper function to print the ASCII encoding of a given byte stream to a given target buffer. | |
static void | write_log (const BSL_LogEvent_event_t *event) |
static void * | work_sink (void *arg) |
void | BSL_openlog (void) |
Opens the event log. | |
void | BSL_closelog (void) |
Closes the event log. | |
int | BSL_LogGetSeverity (int *severity, const char *name) |
Interpret a text name as a severity level. | |
void | BSL_LogSetLeastSeverity (int severity) |
Set the least severity enabled for logging. | |
bool | BSL_LogIsEnabledFor (int severity) |
Determine if a particular severity is being logged. | |
void | BSL_LogEvent (int severity, const char *filename, int lineno, const char *funcname, const char *format,...) |
Log an event. | |
Variables | |
static const char * | sev_names [] |
static atomic_int | least_severity = LOG_DEBUG |
Shared least severity. | |
static BSL_LogEvent_queue_t | event_queue |
Shared safe queue. | |
static pthread_t | thr_sink |
Sink thread ID. | |
static atomic_bool | thr_valid = ATOMIC_VAR_INIT(false) |
True if thr_sink is valid. | |
Implementation of event logging using stderr
output stream.
#define M_OPL_BSL_LogEvent_event_t | ( | ) |
OPLIST for BSL_LogEvent_event_t.
void BSL_closelog | ( | void | ) |
Closes the event log.
This is a mimic to POSIX closelog()
References event_queue, BSL_LogEvent_event_t::message, BSL_LogEvent_event_t::severity, thr_sink, and thr_valid.
uint8_t * BSL_Log_DumpAsHexString | ( | uint8_t * | dstbuf, |
size_t | dstlen, | ||
const uint8_t * | srcbuf, | ||
size_t | srclen | ||
) |
Helper function to print the ASCII encoding of a given byte stream to a given target buffer.
dstbuf | Pointer to a buffer where the C string should go. |
dstlen | The length in bytes of dstbuf |
srcbuf | Pointer to the buffer containing the byte stream to be printed. |
srclen | The length in bytes of srcbuf . |
dstbuf
. It will not exceed dstlen
. Referenced by BSL_AbsSecBlock_Print(), test_RFC9173_AppendixA_Example2_BCB_Acceptor(), and test_RFC9173_AppendixA_Example2_BCB_Source().
void BSL_LogEvent | ( | int | severity, |
const char * | filename, | ||
int | lineno, | ||
const char * | funcname, | ||
const char * | format, | ||
... | |||
) |
Log an event.
severity | The severity from a subset of the POSIX syslog values. | |
[in] | filename | The originating file name, which may include directory parts. |
[in] | lineno | The originating file line number. |
[in] | funcname | The originating function name. |
[in] | format | The log message format string. |
... | Values for the format string. |
References BSL_LogIsEnabledFor(), BSL_LogEvent_event_t::context, event_queue, BSL_LogEvent_event_t::message, BSL_LogEvent_event_t::severity, and thr_valid.
int BSL_LogGetSeverity | ( | int * | severity, |
const char * | name | ||
) |
Interpret a text name as a severity level.
[out] | severity | The associated severity level. |
[in] | name | The text name, which is case insensitive. |
References CHKERR1.
bool BSL_LogIsEnabledFor | ( | int | severity | ) |
Determine if a particular severity is being logged.
This function is multi-thread safe.
severity | The severity from a subset of the POSIX syslog values. |
References least_severity.
Referenced by BSL_LogEvent().
void BSL_LogSetLeastSeverity | ( | int | severity | ) |
Set the least severity enabled for logging.
Other events will be dropped by the logging facility. This function is multi-thread safe.
severity | The severity from a subset of the POSIX syslog values. |
References least_severity.
void BSL_openlog | ( | void | ) |
Opens the event log.
This is a mimic to POSIX openlog()
References BSL_LOG_QUEUE_SIZE, event_queue, BSL_LogEvent_event_t::message, BSL_LogEvent_event_t::severity, thr_sink, and thr_valid.
|
static |