feat: 日志增强功能

This commit is contained in:
2026-04-14 20:52:41 +08:00
parent 579e67a3db
commit e895cdc9de
35 changed files with 1324 additions and 21 deletions

View File

@@ -3,6 +3,7 @@
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
#include <pthread.h>
#include <stdarg.h>
#include <stdbool.h>
@@ -31,6 +32,15 @@
typedef struct omni_file_logger {
FILE *file;
pthread_mutex_t mutex;
char path[PATH_MAX];
size_t current_bytes;
size_t buffered_bytes;
size_t flush_bytes;
size_t max_bytes;
int flush_interval_ms;
int max_files;
int immediate_flush;
uint64_t last_flush_monotonic_ms;
} omni_file_logger_t;
int64_t omni_now_unix_nano(void);
@@ -61,6 +71,7 @@ double omni_duration_ms_to_ns(double ms);
const char *omni_path_base_name(const char *path);
void omni_file_logger_init(omni_file_logger_t *logger, FILE *file);
void omni_file_logger_init_path(omni_file_logger_t *logger, FILE *file, const char *path, int immediate_flush);
void omni_file_logger_destroy(omni_file_logger_t *logger);
int omni_file_logger_write_line(omni_file_logger_t *logger, const char *line);