From 61ec593c95f3210bdfcd22539d43ef507210981f Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Wed, 21 Jan 2026 19:24:49 +0100 Subject: Add logging --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index b509377..7004467 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ ergonomic and productive. It aims to be C99 compliant. - **Slices (`slice`)**: Generic non-owning views into arrays. - **Memory Arena**: Simple block-based arena allocator for bulk memory management. - **File I/O**: Helper functions to read and write entire files with a single call. +- **Logging**: Simple, leveled logging with ANSI colors and timestamps. ## Installation @@ -165,6 +166,24 @@ sb_free(&file_sb); ``` +### 6. Logging + +Simple logging with levels (`ERROR`, `WARN`, `INFO`, `DEBUG`), timestamps, and colors. + +```c +// Set log level (default is INFO) +set_log_level(LOG_DEBUG); + +// Use macros for logging +LOG_INFO_MSG("Starting application..."); +LOG_DEBUG_MSG("Variable x = %d", 42); +LOG_WARN_MSG("Low memory warning"); +LOG_ERROR_MSG("Connection failed"); + +// Environment variable override supported: +// LOG_LEVEL=0 (ERROR) ... 3 (DEBUG) +``` + ## Testing The project includes a test suite using `minunit`. -- cgit v1.2.3