diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-01-21 19:24:49 +0100 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2026-01-21 19:24:49 +0100 |
| commit | 61ec593c95f3210bdfcd22539d43ef507210981f (patch) | |
| tree | 6a74c720944330505977ebfdcf813b05a33ccade /README.md | |
| parent | 7b75ac0962be8ed19a1eca638f600ebee337a18a (diff) | |
| download | nonstd-61ec593c95f3210bdfcd22539d43ef507210981f.tar.gz | |
Add logging
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -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`. |
