|
BSL v1.0.0 - 16.g9d98179
AMMOS Bundle Protocol Security Library (BSL)
|
Logging implementation for the Mock BPA. More...
#include "log.h"#include <BPSecLib_Private.h>#include <BSLConfig.h>#include <pthread.h>#include <stdarg.h>#include <stdio.h>#include <strings.h>#include <syslog.h>#include <sys/time.h>#include <time.h>#include <m-buffer.h>#include <m-string.h>#include <m-atomic.h>
Include dependency graph for log.c:Data Structures | |
| struct | mock_bpa_LogEvent_event_t |
| A single event for the log. More... | |
Macros | |
| #define | MOCK_BPA_LOG_QUEUE_SIZE 100 |
| Number of events to buffer to I/O thread. | |
| #define | M_OPL_mock_bpa_LogEvent_event_t() |
| OPLIST for mock_bpa_LogEvent_event_t. | |
Functions | |
| static void | mock_bpa_LogEvent_event_init (mock_bpa_LogEvent_event_t *obj) |
| static void | mock_bpa_LogEvent_event_deinit (mock_bpa_LogEvent_event_t *obj) |
| static void | mock_bpa_LogEvent_event_init_set (mock_bpa_LogEvent_event_t *obj, const mock_bpa_LogEvent_event_t *src) |
| static void | mock_bpa_LogEvent_event_init_move (mock_bpa_LogEvent_event_t *obj, mock_bpa_LogEvent_event_t *src) |
| static void | mock_bpa_LogEvent_event_set (mock_bpa_LogEvent_event_t *obj, const mock_bpa_LogEvent_event_t *src) |
| static void | write_log (const mock_bpa_LogEvent_event_t *event) |
| static void * | work_sink (void *arg) |
| void | mock_bpa_LogOpen (void) |
| Opens the event log. | |
| void | mock_bpa_LogClose (void) |
| Closes the event log. | |
| int | mock_bpa_LogGetSeverity (int *severity, const char *name) |
| Interpret a text name as a severity level. | |
| void | mock_bpa_LogSetLeastSeverity (int severity) |
| Set the least severity enabled for logging. | |
| bool | mock_bpa_LogIsEnabledFor (int severity) |
| Interface for BSL_HostDescriptors_t::log_is_enabled_for. | |
| void | mock_bpa_LogEvent (const struct timeval *timestamp, int severity, const char *filename, int lineno, const char *funcname, const char *format, va_list args) |
| Interface for BSL_HostDescriptors_t::log_event. | |
Variables | |
| static const char * | sev_names [] |
| static atomic_int | least_severity = LOG_DEBUG |
| Shared least severity. | |
| static mock_bpa_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. | |
Logging implementation for the Mock BPA.
This uses the stderr output stream in a work thread to ensure thread safety of event sources.
| #define M_OPL_mock_bpa_LogEvent_event_t | ( | ) |
OPLIST for mock_bpa_LogEvent_event_t.
| #define MOCK_BPA_LOG_QUEUE_SIZE 100 |
Number of events to buffer to I/O thread.
| void mock_bpa_LogClose | ( | void | ) |
Closes the event log.
This is a mimic to POSIX closelog()
References event_queue, mock_bpa_LogEvent_event_t::message, mock_bpa_LogEvent_event_deinit(), mock_bpa_LogEvent_event_init(), mock_bpa_LogEvent_event_t::severity, thr_sink, thr_valid, and write_log().
Referenced by main(), and suiteTearDown().
| void mock_bpa_LogEvent | ( | const struct timeval * | timestamp, |
| int | severity, | ||
| const char * | filename, | ||
| int | lineno, | ||
| const char * | funcname, | ||
| const char * | format, | ||
| va_list | args | ||
| ) |
Interface for BSL_HostDescriptors_t::log_event.
References BSL_CHKVOID, mock_bpa_LogEvent_event_t::context, event_queue, mock_bpa_LogEvent_event_t::message, mock_bpa_LogEvent_event_deinit(), mock_bpa_LogEvent_event_init(), mock_bpa_LogEvent_event_t::severity, thr_valid, and write_log().
Referenced by MockBPA_Agent_Descriptors().
|
static |
References mock_bpa_LogEvent_event_t::context, mock_bpa_LogEvent_event_t::message, and string_clear().
Referenced by mock_bpa_LogClose(), mock_bpa_LogEvent(), mock_bpa_LogOpen(), and work_sink().
|
static |
|
static |
|
static |
|
static |
| int mock_bpa_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 BSL_CHKERR1, and sev_names.
| bool mock_bpa_LogIsEnabledFor | ( | int | severity | ) |
Interface for BSL_HostDescriptors_t::log_is_enabled_for.
References least_severity.
Referenced by MockBPA_Agent_Descriptors().
| void mock_bpa_LogOpen | ( | void | ) |
Opens the event log.
This is a mimic to POSIX openlog()
References event_queue, mock_bpa_LogEvent_event_t::message, MOCK_BPA_LOG_QUEUE_SIZE, mock_bpa_LogEvent_event_deinit(), mock_bpa_LogEvent_event_init(), mock_bpa_LogEvent_event_t::severity, thr_sink, thr_valid, work_sink(), and write_log().
Referenced by LLVMFuzzerInitialize(), main(), and suiteSetUp().
| void mock_bpa_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.
Referenced by LLVMFuzzerInitialize(), and suiteSetUp().
|
static |
References event_queue, mock_bpa_LogEvent_event_t::message, mock_bpa_LogEvent_event_deinit(), and write_log().
Referenced by mock_bpa_LogOpen().
|
static |
References ASSERT_ARG_NONNULL, and sev_names.
Referenced by mock_bpa_LogClose(), mock_bpa_LogEvent(), mock_bpa_LogOpen(), and work_sink().
|
static |
Shared safe queue.
Referenced by mock_bpa_LogClose(), mock_bpa_LogEvent(), mock_bpa_LogOpen(), and work_sink().
|
static |
Shared least severity.
Referenced by mock_bpa_LogIsEnabledFor(), and mock_bpa_LogSetLeastSeverity().
|
static |
Referenced by mock_bpa_LogGetSeverity(), and write_log().
|
static |
Sink thread ID.
Referenced by mock_bpa_LogClose(), and mock_bpa_LogOpen().
|
static |
True if thr_sink is valid.
Referenced by mock_bpa_LogClose(), mock_bpa_LogEvent(), and mock_bpa_LogOpen().