added logs
Generate and publish developer Wiki / validate-wiki (pull_request) Successful in 15s
Generate and publish developer Wiki / publish-wiki (pull_request) Canceled after 0s

This commit is contained in:
2026-08-07 13:46:16 +00:00
parent 308803053c
commit 581cfb90bd
12 changed files with 110 additions and 83 deletions
+28 -1
View File
@@ -21,10 +21,37 @@
#if ENABLE_LOGGING
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
extern FILE *log_fp;
#define LOG(fmt, ...) do { if (log_fp) { fprintf(log_fp, "[%s] " fmt "\n", __func__, ##__VA_ARGS__); fflush(log_fp); } } while(0)
static inline void openuf_log_emit(FILE *stream, const char *prefix,
const char *fmt, ...)
{
char ts[32];
time_t now = time(NULL);
struct tm tm;
localtime_r(&now, &tm);
strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S", &tm);
fprintf(stream, "[%s]", ts);
if (prefix && prefix[0])
fprintf(stream, " [%s]", prefix);
fputc(' ', stream);
va_list ap;
va_start(ap, fmt);
vfprintf(stream, fmt, ap);
va_end(ap);
fputc('\n', stream);
fflush(stream);
}
#define LOG(fmt, ...) do { if (log_fp) openuf_log_emit(log_fp, __func__, fmt, ##__VA_ARGS__); } while(0)
#define LOGF(stream, fmt, ...) openuf_log_emit(stream, "openuf", fmt, ##__VA_ARGS__)
#else
#define LOG(fmt, ...) do {} while(0)
#define LOGF(stream, fmt, ...) do { (void)(stream); } while(0)
#endif
typedef struct {