ascii-chat 0.11.33
Video chat in your terminal
Loading...
Searching...
No Matches
platform/wasm/stubs/log.c
Go to the documentation of this file.
1
9#include <stdbool.h>
10#include <stddef.h>
11
12// Memory-mapped logging stubs (not supported in WASM)
13asciichat_error_t log_mmap_init_simple(const char *log_path, size_t max_size) {
14 (void)log_path;
15 (void)max_size;
16 return ASCIICHAT_OK; // No-op - mmap logging not supported in WASM
17}
18
20 return false; // mmap logging not active in WASM
21}
22
23void log_mmap_write(int level, const char *file, int line, const char *func, const char *fmt, ...) {
24 (void)level;
25 (void)file;
26 (void)line;
27 (void)func;
28 (void)fmt;
29 // No-op - mmap logging not supported in WASM
30}
31
32bool log_mmap_get_usage(size_t *used, size_t *capacity) {
33 if (used)
34 *used = 0;
35 if (capacity)
36 *capacity = 0;
37 return false;
38}
39
40void log_mmap_rotate(void) {
41 // No-op
42}
43
44// Server status logging stub (not used in mirror mode)
45void server_status_log_append(const char *message) {
46 (void)message;
47 // No-op - server status screen not used in WASM mirror mode
48}
49
50// JSON logging stub
51void log_json_write(int fd, int level, uint64_t time_ns, const char *file, int line, const char *func,
52 const char *json_msg) {
53 (void)fd;
54 (void)level;
55 (void)time_ns;
56 (void)file;
57 (void)line;
58 (void)func;
59 (void)json_msg;
60 // No-op - JSON logging in WASM uses console output instead
61}
62
63// Terminal logging fd selection stub
65 // Route based on level: INFO and below go to stdout, WARN and above go to stderr
66 // This matches the native implementation and allows Emscripten to route to
67 // console.log for INFO/DEBUG/DEV and console.error for WARN/ERROR/FATAL
68 if (level >= 3) { // LOG_WARN = 3, LOG_ERROR = 4, LOG_FATAL = 5
69 return 2; // STDERR_FILENO
70 }
71 return 1; // STDOUT_FILENO (LOG_DEV=0, LOG_DEBUG=1, LOG_INFO=2)
72}
73
74// Session log buffer stub (session screens not used in WASM)
76
78
80 return NULL; // No-op - session log buffer not used in WASM
81}
82
84 (void)buf;
85 // No-op - session log buffer not used in WASM
86}
87
89 (void)buf;
90 // No-op - session log buffer not used in WASM
91}
92
93void session_log_buffer_append(session_log_buffer_t *buf, const char *message) {
94 (void)buf;
95 (void)message;
96 // No-op - session log buffer not used in WASM
97}
98
99size_t session_log_buffer_get_recent(session_log_buffer_t *buf, session_log_entry_t *out_entries, size_t max_count) {
100 (void)buf;
101 (void)out_entries;
102 (void)max_count;
103 return 0; // No entries in WASM
104}
105
107 // No-op - mmap logging not used in WASM
108}
⚠️‼️ Comprehensive thread-local error context system for ascii-chat
unsigned long long uint64_t
Definition common.h:59
asciichat_error_t
Error and exit codes - unified status values (0-255)
Definition error_codes.h:49
@ ASCIICHAT_OK
Definition error_codes.h:51
log_level_t
Logging levels enumeration.
Definition types.h:29
Thread-safe circular log buffer for session screens (status, splash)
📝 Logging API with multiple log levels and terminal output control
session_log_buffer_t * session_log_buffer_create(void)
Create a new session log buffer instance.
void log_mmap_rotate(void)
Rotate the mmap log (tail-keeping rotation)
bool log_mmap_is_active(void)
Check if mmap logging is active.
void session_log_buffer_clear(session_log_buffer_t *buf)
Clear all log entries from buffer.
void log_mmap_write(int level, const char *file, int line, const char *func, const char *fmt,...)
Write a log entry directly to the mmap'd file (lock-free)
bool log_mmap_get_usage(size_t *used, size_t *capacity)
Get current mmap log usage.
int terminal_choose_log_fd(log_level_t level)
Choose output file descriptor for logging based on level and interactivity.
void server_status_log_append(const char *message)
void log_mmap_destroy(void)
Shutdown mmap logging.
void session_log_buffer_append(session_log_buffer_t *buf, const char *message)
Append a log message to the buffer.
asciichat_error_t log_mmap_init_simple(const char *log_path, size_t max_size)
Initialize mmap logging with simple parameters.
void log_json_write(int fd, int level, uint64_t time_ns, const char *file, int line, const char *func, const char *json_msg)
size_t session_log_buffer_get_recent(session_log_buffer_t *buf, session_log_entry_t *out_entries, size_t max_count)
Get recent log entries from buffer.
void session_log_buffer_destroy(session_log_buffer_t *buf)
Cleanup session log buffer instance.
ClangTool/LibTooling compatibility shim for stdbool.h.
Internal circular buffer structure.
Single log entry with sequence number for ordering.