Oakfield API Documentation 1.0.0
Numerical core APIs
Loading...
Searching...
No Matches
async_logger.h
Go to the documentation of this file.
1
5#ifndef OAKFIELD_ASYNC_LOGGER_H
6#define OAKFIELD_ASYNC_LOGGER_H
7
8#include <stdbool.h>
9#include <stddef.h>
10#include <stdint.h>
11
12#include "field.h"
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
19#define SIM_ASYNC_LOGGER_MESSAGE_MAX 255U
20
32
42
46typedef struct SimAsyncLogger {
48 size_t capacity;
49 volatile size_t head;
50 volatile size_t tail;
52
61
68
79SimResult sim_async_logger_log(SimAsyncLogger *logger, SimLogLevel level, const char *message);
80
89
96
97#ifdef __cplusplus
98}
99#endif
100
101#endif /* OAKFIELD_ASYNC_LOGGER_H */
void sim_async_logger_clear(SimAsyncLogger *logger)
Clear all pending log entries without releasing internal storage.
void sim_async_logger_destroy(SimAsyncLogger *logger)
Destroy an asynchronous logger instance and release its storage.
SimResult sim_async_logger_log(SimAsyncLogger *logger, SimLogLevel level, const char *message)
Attempt to append a log record without blocking.
#define SIM_ASYNC_LOGGER_MESSAGE_MAX
Definition async_logger.h:19
SimResult sim_async_logger_init(SimAsyncLogger *logger, size_t capacity)
Initialize the asynchronous logger with a ring buffer of at least capacity elements.
bool sim_async_logger_pop(SimAsyncLogger *logger, SimAsyncLogRecord *out_record)
Drain the next pending log record.
SimLogLevel
Severity levels emitted by the asynchronous logger.
Definition async_logger.h:24
@ SIM_LOG_LEVEL_INFO
Definition async_logger.h:27
@ SIM_LOG_LEVEL_WARN
Definition async_logger.h:28
@ SIM_LOG_LEVEL_TRACE
Definition async_logger.h:25
@ SIM_LOG_LEVEL_DEBUG
Definition async_logger.h:26
@ SIM_LOG_LEVEL_FATAL
Definition async_logger.h:30
@ SIM_LOG_LEVEL_ERROR
Definition async_logger.h:29
Multidimensional contiguous field abstraction with configurable layout.
SimResult
Return codes shared by libsimcore modules.
Definition field.h:29
Log entry materialized when records are drained from the ring buffer.
Definition async_logger.h:36
SimLogLevel level
Definition async_logger.h:39
uint32_t thread_id
Definition async_logger.h:38
char message[SIM_ASYNC_LOGGER_MESSAGE_MAX+1U]
Definition async_logger.h:40
uint64_t timestamp_ns
Definition async_logger.h:37
Lock-free ring buffer logger supporting multiple producers and a single consumer.
Definition async_logger.h:46
volatile size_t tail
Definition async_logger.h:50
SimAsyncLogRecord * records
Definition async_logger.h:47
volatile size_t head
Definition async_logger.h:49
size_t capacity
Definition async_logger.h:48