ascii-chat
Binary v0.16.114-28-gf5913657f
Library lib/v0.3.2-3302-gf5913657f
Video chat in your terminal
Loading...
Searching...
No Matches
wasm/stubs/log.c
Go to the documentation of this file.
1
6
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, const char *json_msg) {
52 (void)fd;
53 (void)level;
54 (void)time_ns;
55 (void)file;
56 (void)line;
57 (void)func;
58 (void)json_msg;
59 // No-op - JSON logging in WASM uses console output instead
60}
61
62// Terminal logging fd selection stub
64 // Route based on level: INFO and below go to stdout, WARN and above go to stderr
65 // This matches the native implementation and allows Emscripten to route to
66 // console.log for INFO/DEBUG/DEV and console.error for WARN/ERROR/FATAL
67 if (level >= 3) { // LOG_WARN = 3, LOG_ERROR = 4, LOG_FATAL = 5
68 return 2; // STDERR_FILENO
69 }
70 return 1; // STDOUT_FILENO (LOG_DEV=0, LOG_DEBUG=1, LOG_INFO=2)
71}
72
73void log_mmap_destroy(void) {
74 // No-op - mmap logging not used in WASM
75}
Synchronized per-thread pending error stacks and value snapshots. SET_ERRNO pushes,...
unsigned long long uint64_t
asciichat_error_t
Error and exit codes - unified status values (0-255).
Definition error_codes.h:48
@ ASCIICHAT_OK
Definition error_codes.h:50
log_level_t
Logging levels enumeration.
Definition log/types.h:33
📝 Logging API with multiple log levels and terminal output control
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 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)
void server_status_log_append(const char *message)
void log_mmap_destroy(void)
Shutdown mmap logging.
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)