|
ascii-chat 0.8.38
Real-time terminal-based video chat with ASCII art conversion
|
📝 Multi-level logging with terminal color support, file rotation, and async output More...
Go to the source code of this file.
Data Structures | |
| struct | log_context_t |
Macros | |
| #define | LOG_COLOR_COUNT 8 /* DEV, DEBUG, WARN, INFO, ERROR, FATAL, GREY, RESET */ |
| #define | LOGGING_INTERNAL_ERROR(error, message, ...) |
Functions | |
| __attribute__ ((weak)) | |
| const char * | get_level_string_padded (log_level_t level) |
| Get padded level string for consistent alignment. | |
| size_t | get_current_time_formatted (char *time_buf) |
| char * | format_message (const char *format, va_list args) |
| void | log_init (const char *filename, log_level_t level, bool force_stderr, bool use_mmap) |
| void | log_destroy (void) |
| void | log_set_level (log_level_t level) |
| log_level_t | log_get_level (void) |
| void | log_set_terminal_output (bool enabled) |
| bool | log_get_terminal_output (void) |
| void | log_set_force_stderr (bool enabled) |
| bool | log_get_force_stderr (void) |
| void | log_set_json_output (int fd) |
| void | log_disable_file_output (void) |
| asciichat_error_t | log_set_format (const char *format_str, bool console_only) |
| bool | log_lock_terminal (void) |
| void | log_unlock_terminal (bool previous_state) |
| void | log_set_flush_delay (unsigned int delay_ms) |
| void | log_truncate_if_large (void) |
| void | log_msg (log_level_t level, const char *file, int line, const char *func, const char *fmt,...) |
| void | log_terminal_msg (log_level_t level, const char *file, int line, const char *func, const char *fmt,...) |
| void | log_plain_msg (const char *fmt,...) |
| void | log_plain_stderr_msg (const char *fmt,...) |
| void | log_plain_stderr_nonewline_msg (const char *fmt,...) |
| void | log_file_msg (const char *fmt,...) |
| 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,...) |
| 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,...) |
| void | log_redetect_terminal_capabilities (void) |
| const char ** | log_get_color_array (void) |
| const char * | log_level_color (log_color_t color) |
| void | log_init_colors (void) |
| void | log_set_color_scheme (const color_scheme_t *scheme) |
| asciichat_error_t | log_enable_mmap (const char *log_path) |
| asciichat_error_t | log_enable_mmap_sized (const char *log_path, size_t max_size) |
| void | log_disable_mmap (void) |
| void | log_shutdown_begin (void) |
| void | log_shutdown_end (void) |
| void | log_cleanup_colors (void) |
| Clean up compiled color scheme. | |
| size_t | log_recolor_plain_entry (const char *plain_line, char *colored_buf, size_t buf_size) |
| Recolor a plain (non-colored) log line with proper ANSI codes. | |
| void | log_console_impl (log_level_t level, const char *file, int line, const char *func, const char *message) |
| void * | log_get_template (void) |
| Get the current log format template. | |
📝 Multi-level logging with terminal color support, file rotation, and async output
Definition in file log/logging.c.
| #define LOG_COLOR_COUNT 8 /* DEV, DEBUG, WARN, INFO, ERROR, FATAL, GREY, RESET */ |
Definition at line 146 of file log/logging.c.
| #define LOGGING_INTERNAL_ERROR | ( | error, | |
| message, | |||
| ... | |||
| ) |
Definition at line 165 of file log/logging.c.
| __attribute__ | ( | (weak) | ) |
Definition at line 39 of file log/logging.c.
| char * format_message | ( | const char * | format, |
| va_list | args | ||
| ) |
Definition at line 224 of file log/logging.c.
References args, LOGGING_INTERNAL_ERROR, and safe_vsnprintf().
Referenced by asciichat_fatal_with_context(), asciichat_set_errno_with_message(), asciichat_set_errno_with_system_error_and_message(), and log_labeled().
| size_t get_current_time_formatted | ( | char * | time_buf | ) |
Definition at line 192 of file log/logging.c.
References LOGGING_INTERNAL_ERROR, platform_localtime(), safe_snprintf(), and time_get_realtime_ns().
Referenced by log_msg(), log_plain_msg(), and log_terminal_msg().
| const char * get_level_string_padded | ( | log_level_t | level | ) |
Get padded level string for consistent alignment.
Returns level names padded to 5 characters for visual alignment. Used consistently in both colored and plain text formatters to ensure grep pattern matching works correctly.
| level | Log level |
Definition at line 114 of file log/logging.c.
Referenced by log_template_apply().
| void log_cleanup_colors | ( | void | ) |
Clean up compiled color scheme.
Should be called AFTER memory reporting to ensure colored output. Safe to call multiple times (idempotent).
Definition at line 1666 of file log/logging.c.
References colorscheme_cleanup_compiled().
Referenced by asciichat_shared_destroy().
| void log_console_impl | ( | log_level_t | level, |
| const char * | file, | ||
| int | line, | ||
| const char * | func, | ||
| const char * | message | ||
| ) |
Definition at line 1932 of file log/logging.c.
References log_json_async_safe(), platform_write_all(), and terminal_choose_log_fd().
| void log_destroy | ( | void | ) |
Definition at line 587 of file log/logging.c.
References grep_destroy(), log_mmap_destroy(), log_mmap_is_active(), log_template_free(), mutex_destroy(), and platform_close().
Referenced by asciichat_shared_destroy(), main(), and server_main().
| void log_disable_file_output | ( | void | ) |
Definition at line 658 of file log/logging.c.
References platform_close().
| void log_disable_mmap | ( | void | ) |
Definition at line 1628 of file log/logging.c.
References log_mmap_destroy(), and log_mmap_is_active().
| asciichat_error_t log_enable_mmap | ( | const char * | log_path | ) |
Definition at line 1609 of file log/logging.c.
References log_enable_mmap_sized().
| asciichat_error_t log_enable_mmap_sized | ( | const char * | log_path, |
| size_t | max_size | ||
| ) |
Definition at line 1613 of file log/logging.c.
References log_mmap_init_simple().
Referenced by log_enable_mmap().
| void log_file_msg | ( | const char * | fmt, |
| ... | |||
| ) |
Definition at line 1316 of file log/logging.c.
References args, log_mmap_is_active(), log_mmap_write(), and safe_vsnprintf().
Referenced by platform_print_backtrace_symbols().
| const char ** log_get_color_array | ( | void | ) |
Definition at line 1478 of file log/logging.c.
References log_init_colors().
Referenced by log_level_color(), log_msg(), and log_recolor_plain_entry().
| bool log_get_force_stderr | ( | void | ) |
Definition at line 650 of file log/logging.c.
Referenced by terminal_choose_log_fd().
| log_level_t log_get_level | ( | void | ) |
Definition at line 627 of file log/logging.c.
Referenced by options_init().
| void * log_get_template | ( | void | ) |
Get the current log format template.
Returns the compiled log format template used by the logging system. This is used by platform code (e.g., backtrace formatting) to format log entries using the same template as the rest of the logging system. Returns void* (opaque) to avoid circular dependency with format.h.
Definition at line 1970 of file log/logging.c.
Referenced by platform_print_backtrace_symbols().
| bool log_get_terminal_output | ( | void | ) |
Definition at line 642 of file log/logging.c.
Referenced by config_load_and_apply().
Definition at line 507 of file log/logging.c.
References log_mmap_init_simple(), log_redetect_terminal_capabilities(), log_set_format(), mutex_init(), platform_close(), platform_open(), and safe_fprintf().
Referenced by asciichat_shared_init(), client_init_with_args(), main(), main(), mirror_init_with_args(), and options_init().
| void log_init_colors | ( | void | ) |
Definition at line 1517 of file log/logging.c.
References colorscheme_compile_scheme(), colorscheme_get_active_scheme(), detect_terminal_background(), and g_colorscheme_mutex.
Referenced by log_get_color_array(), and main().
| const char * log_level_color | ( | log_color_t | color | ) |
Definition at line 1502 of file log/logging.c.
References log_get_color_array().
Referenced by colored_string().
| bool log_lock_terminal | ( | void | ) |
Definition at line 710 of file log/logging.c.
References asciichat_thread_self().
Referenced by client_crypto_handshake(), client_main(), discovery_tui_select(), prompt_password(), prompt_unknown_host(), and session_display_render_frame().
| void log_msg | ( | log_level_t | level, |
| const char * | file, | ||
| int | line, | ||
| const char * | func, | ||
| const char * | fmt, | ||
| ... | |||
| ) |
Definition at line 946 of file log/logging.c.
References args, colorize_log_message(), g_color_flag_passed, g_color_flag_value, get_current_time_formatted(), log_get_color_array(), log_json_write(), log_mmap_is_active(), log_mmap_write(), LOGGING_INTERNAL_ERROR, platform_log_hook(), safe_fprintf(), safe_vsnprintf(), terminal_choose_log_fd(), and time_get_realtime_ns().
Referenced by handle_remote_log_packet_from_client().
| 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, | ||
| ... | |||
| ) |
| 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, | ||
| ... | |||
| ) |
Definition at line 1399 of file log/logging.c.
References args.
Referenced by disconnect_client_for_bad_data(), and threaded_send_client_join_packet().
| void log_plain_msg | ( | const char * | fmt, |
| ... | |||
| ) |
Definition at line 1133 of file log/logging.c.
References args, asciichat_thread_self(), colorize_log_message(), get_current_time_formatted(), log_json_write(), log_mmap_is_active(), log_mmap_write(), safe_fprintf(), safe_vsnprintf(), shutdown_is_requested(), terminal_choose_log_fd(), terminal_should_color_output(), and time_get_realtime_ns().
| void log_plain_stderr_msg | ( | const char * | fmt, |
| ... | |||
| ) |
Definition at line 1288 of file log/logging.c.
References args, and shutdown_is_requested().
| void log_plain_stderr_nonewline_msg | ( | const char * | fmt, |
| ... | |||
| ) |
Definition at line 1302 of file log/logging.c.
References args, and shutdown_is_requested().
| size_t log_recolor_plain_entry | ( | const char * | plain_line, |
| char * | colored_buf, | ||
| size_t | buf_size | ||
| ) |
Recolor a plain (non-colored) log line with proper ANSI codes.
Parses plain log format: [TIMESTAMP] [LEVEL] [tid:THREAD_ID] FILE:LINE in FUNC(): MESSAGE And recolors it with appropriate ANSI codes matching the colored format.
Definition at line 1680 of file log/logging.c.
References colorize_log_message(), file_path, log_get_color_array(), and safe_snprintf().
| void log_redetect_terminal_capabilities | ( | void | ) |
Definition at line 1453 of file log/logging.c.
References detect_terminal_capabilities().
Referenced by log_init(), and main().
| void log_set_color_scheme | ( | const color_scheme_t * | scheme | ) |
Definition at line 1572 of file log/logging.c.
References colorscheme_compile_scheme(), detect_terminal_background(), and g_colorscheme_mutex.
Referenced by main(), and options_init().
| void log_set_flush_delay | ( | unsigned int | delay_ms | ) |
Definition at line 723 of file log/logging.c.
| void log_set_force_stderr | ( | bool | enabled | ) |
Definition at line 646 of file log/logging.c.
References enabled.
Referenced by main(), session_client_like_run(), and session_display_create().
| asciichat_error_t log_set_format | ( | const char * | format_str, |
| bool | console_only | ||
| ) |
Definition at line 669 of file log/logging.c.
References log_template_free(), and log_template_parse().
Referenced by log_init(), and main().
| void log_set_json_output | ( | int | fd | ) |
Definition at line 654 of file log/logging.c.
Referenced by main().
| void log_set_level | ( | log_level_t | level | ) |
Definition at line 622 of file log/logging.c.
Referenced by options_init().
| void log_set_terminal_output | ( | bool | enabled | ) |
Definition at line 631 of file log/logging.c.
References enabled, and options_get().
Referenced by display_disable_logging_for_first_frame(), main(), options_init(), server_connection_cleanup(), server_connection_close(), server_connection_establish(), session_client_like_run(), and session_render_loop().
| void log_shutdown_begin | ( | void | ) |
Definition at line 1639 of file log/logging.c.
Referenced by asciichat_shared_destroy().
| void log_shutdown_end | ( | void | ) |
Definition at line 1650 of file log/logging.c.
Referenced by asciichat_shared_destroy().
| void log_terminal_msg | ( | log_level_t | level, |
| const char * | file, | ||
| int | line, | ||
| const char * | func, | ||
| const char * | fmt, | ||
| ... | |||
| ) |
Definition at line 1112 of file log/logging.c.
References args, get_current_time_formatted(), and time_get_realtime_ns().
| void log_truncate_if_large | ( | void | ) |
Definition at line 727 of file log/logging.c.
Referenced by main().
| void log_unlock_terminal | ( | bool | previous_state | ) |
Definition at line 716 of file log/logging.c.
Referenced by client_crypto_handshake(), discovery_tui_select(), prompt_password(), prompt_unknown_host(), and session_display_render_frame().