|
ascii-chat 0.6.0
Real-time terminal-based video chat with ASCII art conversion
|
📝 Logging API with multiple log levels and terminal output control More...
Go to the source code of this file.
Data Structures | |
| struct | log_buffer_entry_t |
| A single buffered log entry. More... | |
Macros | |
| #define | LOG_ATOMIC_UINT64 _Atomic uint64_t |
| #define | LOG_ATOMIC_UINT64_INIT(val) val |
| #define | DEFAULT_LOG_LEVEL LOG_DEBUG |
| Default log level for debug builds (DEBUG and above) | |
| #define | MAX_LOG_SIZE (3 * 1024 * 1024) |
| Maximum log file size in bytes (3MB) before rotation. | |
| #define | MAX_TERMINAL_BUFFER_SIZE (64 * 1024) |
| Maximum size of terminal output buffer (64KB) | |
| #define | MAX_TERMINAL_BUFFER_ENTRIES 256 |
| Maximum number of buffered log entries. | |
| #define | LOG_MSG_BUFFER_SIZE 4096 |
| Maximum size of a single log message (including formatting) | |
| #define | LOG_MMAP_MSG_BUFFER_SIZE 1024 |
| Maximum size of a log message in mmap mode. | |
| #define | LOG_HEADER_BUFFER_SIZE 512 |
| Maximum size of a log header (timestamp, level, file:line:func) | |
| #define | LOG_TIMESTAMP_BUFFER_SIZE 32 |
| Maximum size of a timestamp string. | |
| #define | LOG_COMPILE_LEVEL LOG_DEV |
| Compile-time minimum log level (DEV keeps all, allowing runtime -vvv) | |
| #define | log_every(log_level, interval_us, fmt, ...) |
| Rate-limited logging macro (thread-safe) | |
Logging Macros | |
| |
| #define | log_dev(...) log_msg(LOG_DEV, __FILE__, __LINE__, __func__, __VA_ARGS__) |
| Log a DEV message (most verbose, development only) | |
| #define | log_debug(...) log_msg(LOG_DEBUG, __FILE__, __LINE__, __func__, __VA_ARGS__) |
| Log a DEBUG message. | |
| #define | log_info(...) log_msg(LOG_INFO, __FILE__, __LINE__, __func__, __VA_ARGS__) |
| Log an INFO message. | |
| #define | log_warn(...) log_msg(LOG_WARN, __FILE__, __LINE__, __func__, __VA_ARGS__) |
| Log a WARN message. | |
| #define | log_error(...) log_msg(LOG_ERROR, __FILE__, __LINE__, __func__, __VA_ARGS__) |
| Log an ERROR message. | |
| #define | log_fatal(...) log_msg(LOG_FATAL, __FILE__, __LINE__, __func__, __VA_ARGS__) |
| Log a FATAL message. | |
| #define | log_plain(...) log_plain_msg(__VA_ARGS__) |
| Plain logging - writes to both log file and stderr without timestamps or log levels. | |
| #define | log_plain_stderr(...) log_plain_stderr_msg(__VA_ARGS__) |
| Plain logging to stderr with newline. | |
| #define | log_plain_stderr_nonewline(...) log_plain_stderr_nonewline_msg(__VA_ARGS__) |
| Plain logging to stderr without newline - for interactive prompts. | |
| #define | log_file(...) log_file_msg(__VA_ARGS__) |
| File-only logging - writes to log file only, no stderr output. | |
Rate-Limited Logging Macros | |
| #define | log_dev_every(interval_us, fmt, ...) log_every(DEV, interval_us, fmt, ##__VA_ARGS__) |
| Rate-limited DEV logging. | |
| #define | log_debug_every(interval_us, fmt, ...) log_every(DEBUG, interval_us, fmt, ##__VA_ARGS__) |
| Rate-limited DEBUG logging. | |
| #define | log_info_every(interval_us, fmt, ...) log_every(INFO, interval_us, fmt, ##__VA_ARGS__) |
| Rate-limited INFO logging. | |
| #define | log_warn_every(interval_us, fmt, ...) log_every(WARN, interval_us, fmt, ##__VA_ARGS__) |
| Rate-limited WARN logging. | |
| #define | log_error_every(interval_us, fmt, ...) log_every(ERROR, interval_us, fmt, ##__VA_ARGS__) |
| Rate-limited ERROR logging. | |
| #define | log_fatal_every(interval_us, fmt, ...) log_every(FATAL, interval_us, fmt, ##__VA_ARGS__) |
| Rate-limited FATAL logging. | |
Typedefs | |
| typedef struct log_mmap_config | log_mmap_config_t |
Enumerations | |
| enum | log_level_t { LOG_DEV = 0 , LOG_DEBUG , LOG_INFO , LOG_WARN , LOG_ERROR , LOG_FATAL } |
| Logging levels enumeration. More... | |
| enum | log_color_t { LOG_COLOR_DEV = 0 , LOG_COLOR_DEBUG = 1 , LOG_COLOR_INFO = 2 , LOG_COLOR_WARN = 3 , LOG_COLOR_ERROR = 4 , LOG_COLOR_FATAL = 5 , LOG_COLOR_RESET = 6 } |
| Color enum for logging - indexes into color arrays. More... | |
Functions | |
| void | log_init (const char *filename, log_level_t level, bool force_stderr, bool use_mmap) |
| Initialize the logging system. | |
| void | log_destroy (void) |
| Destroy the logging system and close log file. | |
| void | log_set_level (log_level_t level) |
| Set the minimum log level. | |
| log_level_t | log_get_level (void) |
| Get the current minimum log level. | |
| void | log_set_terminal_output (bool enabled) |
| Control stderr output to terminal. | |
| bool | log_get_terminal_output (void) |
| Get current terminal output setting. | |
| void | log_set_force_stderr (bool enabled) |
| Force all terminal log output to stderr. | |
| bool | log_get_force_stderr (void) |
| Get current force_stderr setting. | |
| void | log_truncate_if_large (void) |
| Manually truncate large log files. | |
| void | log_msg (log_level_t level, const char *file, int line, const char *func, const char *fmt,...) |
| Log a message at a specific level. | |
| void | log_plain_msg (const char *fmt,...) |
| Plain logging without timestamps or levels. | |
| void | log_plain_stderr_msg (const char *fmt,...) |
| Plain logging to stderr with newline. | |
| void | log_plain_stderr_nonewline_msg (const char *fmt,...) |
| Plain logging to stderr without trailing newline. | |
| void | log_file_msg (const char *fmt,...) |
| Log to file only, no stderr output. | |
| void | log_labeled (const char *label, log_color_t color, const char *message,...) |
| Print a labeled message with color. | |
| const char * | log_level_color (log_color_t color) |
| Get color string for a given color enum. | |
| const char ** | log_get_color_array (void) |
| Get the appropriate color array based on terminal capabilities. | |
| void | log_redetect_terminal_capabilities (void) |
| Re-detect terminal capabilities after logging is initialized. | |
| bool | log_lock_terminal (void) |
| Lock terminal output for exclusive access by the calling thread. | |
| void | log_unlock_terminal (bool previous_state) |
| Release terminal lock and flush buffered messages. | |
| void | log_set_flush_delay (unsigned int delay_ms) |
| Set the delay between flushing buffered log entries. | |
| char * | format_message (const char *format, va_list args) |
| Format a message using va_list. | |
| size_t | get_current_time_formatted (char *time_buf) |
| Get current time as formatted string. | |
| asciichat_error_t | log_network_message (socket_t sockfd, const struct crypto_context_t *crypto_ctx, log_level_t level, remote_log_direction_t direction, const char *fmt,...) |
| Send a formatted log message over the network. | |
| asciichat_error_t | log_net_message (socket_t sockfd, const struct crypto_context_t *crypto_ctx, log_level_t level, remote_log_direction_t direction, const char *file, int line, const char *func, const char *fmt,...) |
| Log a message to all destinations (network, file, and terminal). | |
| asciichat_error_t | log_enable_mmap (const char *log_path) |
| Enable lock-free mmap-based logging. | |
| asciichat_error_t | log_enable_mmap_sized (const char *log_path, size_t max_size) |
| Enable lock-free mmap logging with custom file size. | |
| void | log_disable_mmap (void) |
| Disable mmap logging and return to mutex-based logging. | |
| void | log_shutdown_begin (void) |
| Begin shutdown phase - disable console logging but keep file logging. | |
| void | log_shutdown_end (void) |
| End shutdown phase - restore previous logging settings. | |
📝 Logging API with multiple log levels and terminal output control
Definition in file log/logging.h.