From 788ed3631a802952342804ca1b99070cfe508efd Mon Sep 17 00:00:00 2001 From: Andrei Gramakov Date: Fri, 7 Nov 2025 16:30:29 +0100 Subject: [PATCH 1/5] Add log.c to the license file and comparison with log.c --- LICENSE | 3 ++- README.md | 79 ++++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 71 insertions(+), 11 deletions(-) diff --git a/LICENSE b/LICENSE index 29bfd8a..c578c68 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ MIT License -Copyright (c) 2025 Andrei Gramakov +Copyright (c) 2020 rxi (original log.c) +Copyright (c) 2025 Andrei Gramakov (microlog modifications and extensions) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 027950d..703aa9f 100644 --- a/README.md +++ b/README.md @@ -17,21 +17,21 @@ In the default configuration it looks like this: -|| -|-| -|Picture 1 - default configuration: no time, long default levels, source location, no topics, no colors| +| `` | +| ------------------------------------------------------------------------------------------------------ | +| Picture 1 - default configuration: no time, long default levels, source location, no topics, no colors | ...but in can be very minimalistic : -|| -|-| -|Picture 2 - short levels, no colors, no time, no source location| +| `` | +| ---------------------------------------------------------------- | +| Picture 2 - short levels, no colors, no time, no source location | ... or feature-rich: -| | -|-| -|Picture 3 - time, custom prefix for MsgID, custom syslog levels, topics, source location, colors| +| `` | +| ------------------------------------------------------------------------------------------------ | +| Picture 3 - time, custom prefix for MsgID, custom syslog levels, topics, source location, colors | The project is based on the following core principles: @@ -52,6 +52,9 @@ The project is based on the following core principles: - [3. Extend](#3-extend) - [Advanced Usage](#advanced-usage) - [Contributing](#contributing) + - [Comparison with log.c](#comparison-with-logc) + - [Core Differences](#core-differences) + - [Key Capabilities Unique to microlog](#key-capabilities-unique-to-microlog) - [Changelog](#changelog) - [License](#license) - [Credits](#credits) @@ -125,7 +128,7 @@ CPMAddPackage("gh:an-dr/microlog@6.4.5") target_link_libraries(${PROJECT_NAME} PUBLIC microlog::microlog) target_compile_definitions( microlog PRIVATE ULOG_BUILD_COLOR=1) # configuration - + # Or use a user-defined configuration header `ulog_config.h`: # target_compile_definitions(microlog PRIVATE ULOG_BUILD_CONFIG_HEADER_ENABLED=1) # target_include_directories(microlog PRIVATE path/to/directory/containing/ulog_config.h) @@ -164,6 +167,62 @@ Add missing functionalities via API or use predefined extensions. See [Extension Contributions are welcome! Please read the [CONTRIBUTING.md](CONTRIBUTING.md) for details, I tried to keep it simple. +## Comparison with log.c + +microlog started as a fork of [rxi/log.c](https://github.com/rxi/log.c) (~150 lines, 3.3k stars) but evolved into a fundamentally different architecture (~2,500 lines) optimized for embedded systems and advanced filtering. + +### Core Differences + +**rxi/log.c**: Minimalist runtime-only config. Fixed ~5KB footprint, 6 levels, simple callbacks. +**microlog**: Compile-time feature selection. Configurable 200 bytes to ~15KB, 8 renameable levels, multi-dimensional filtering. + +| Feature | log.c | microlog | +| ------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------ | +| **Philosofy** | Simple-to-use, Minimalist for average use | Simple-to-use, extensible and configurable for diverse needs | +| **Configuration** | Color, verbosity | ✅ Compile-time feature selection + optional runtime | +| **Runtime Configuration** | Only verbosity | ✅ Verbosity, color, time, prefix, source location, topics (Disablable feature) | +| **Zero-Overhead Disable** | Args are evaluated | ✅ True no-op with `ULOG_BUILD_DISABLED` | +| **Log Levels** | 6 fixed | 8, runtime renameable (e.g., syslog) | +| **Filtering** | Global + per-callback | Per-output + per-topic + global | +| **Topics/Subsystems** | Manual prefixes | ✅ Full support with filtering per topic and routing | +| **Output Routing** | All outputs get all logs | ✅ Route topics to specific or all outputs | +| **Memory** | Static | ✅ Static or dynamic (user choice) | +| **Build Systems** | Manual integration | ✅ CMake, Meson, CPM packages | +| **Platform Helpers** | DIY | ✅ FreeRTOS, Zephyr, ThreadX, pthread, Win32 | + +### Key Capabilities Unique to microlog + +**1. Multi-Dimensional Filtering** - Per-output AND per-topic levels: + +```c +ulog_topic_add("Credentials", secure_file_only, ULOG_LEVEL_TRACE); +ulog_topic_add("Network", ULOG_OUTPUT_ALL, ULOG_LEVEL_DEBUG); +ulog_output_level_set(ULOG_OUTPUT_STDOUT, ULOG_LEVEL_ERROR); // Console: errors only +``` + +**2. True Zero-Overhead Disable** - Arguments not evaluated: + +```c +ulog_info("Result: %d", expensive()); // With ULOG_BUILD_DISABLED=1 → ((void)0) +``` + +**3. Custom Log Levels** - Redefine all 8 at runtime: + +```c +ulog_level_descriptor syslog = {ULOG_LEVEL_7, + {"DEBUG", "INFO", "NOTICE", "WARN", "ERR", "CRIT", "ALERT", "EMERG"}}; +ulog_level_set_new_levels(&syslog); +``` + +**4. Fine-Grained Code Control** - 12+ build flags to strip features: + +``` +-DULOG_BUILD_SOURCE_LOCATION 0 // Remove file:line +-DULOG_BUILD_TIME 0 // Remove timestamps +-DULOG_BUILD_COLOR 0 // Remove ANSI codes +... +``` + ## Changelog See [CHANGELOG.md](CHANGELOG.md) for details. From 8ddeca1246d716a8bae1cc235b3b1abc4cb0c615 Mon Sep 17 00:00:00 2001 From: Andrei Gramakov Date: Fri, 7 Nov 2025 16:38:33 +0100 Subject: [PATCH 2/5] Fixes --- README.md | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 703aa9f..c14c169 100644 --- a/README.md +++ b/README.md @@ -17,19 +17,19 @@ In the default configuration it looks like this: -| `` | +| `` | | ------------------------------------------------------------------------------------------------------ | | Picture 1 - default configuration: no time, long default levels, source location, no topics, no colors | ...but in can be very minimalistic : -| `` | +| `` | | ---------------------------------------------------------------- | | Picture 2 - short levels, no colors, no time, no source location | ... or feature-rich: -| `` | +| `` | | ------------------------------------------------------------------------------------------------ | | Picture 3 - time, custom prefix for MsgID, custom syslog levels, topics, source location, colors | @@ -128,7 +128,7 @@ CPMAddPackage("gh:an-dr/microlog@6.4.5") target_link_libraries(${PROJECT_NAME} PUBLIC microlog::microlog) target_compile_definitions( microlog PRIVATE ULOG_BUILD_COLOR=1) # configuration - + # Or use a user-defined configuration header `ulog_config.h`: # target_compile_definitions(microlog PRIVATE ULOG_BUILD_CONFIG_HEADER_ENABLED=1) # target_include_directories(microlog PRIVATE path/to/directory/containing/ulog_config.h) @@ -169,27 +169,31 @@ Contributions are welcome! Please read the [CONTRIBUTING.md](CONTRIBUTING.md) fo ## Comparison with log.c -microlog started as a fork of [rxi/log.c](https://github.com/rxi/log.c) (~150 lines, 3.3k stars) but evolved into a fundamentally different architecture (~2,500 lines) optimized for embedded systems and advanced filtering. +microlog started as a fork of [rxi/log.c](https://github.com/rxi/log.c) (~150 lines, 3.3k stars) but evolved into a fundamentally different architecture (~2,500 lines) optimized for embedded systems and advanced filtering. microlog's larger codebase is offset by compile-time feature stripping - +a minimal build can match log.c's footprint. ### Core Differences -**rxi/log.c**: Minimalist runtime-only config. Fixed ~5KB footprint, 6 levels, simple callbacks. -**microlog**: Compile-time feature selection. Configurable 200 bytes to ~15KB, 8 renameable levels, multi-dimensional filtering. +**rxi/log.c**: Minimalist and ready to use. Fixed footprint, 6 levels, simple callbacks. +**microlog**: Compile-time feature selection. Configurable footprint, 8 renameable levels, multi-dimensional filtering. -| Feature | log.c | microlog | -| ------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------ | -| **Philosofy** | Simple-to-use, Minimalist for average use | Simple-to-use, extensible and configurable for diverse needs | +| Feature | log.c | microlog | +| ------------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------- | +| **Philosophy** | Simple-to-use, Minimalist for average use | Simple-to-use, extensible and configurable for diverse needs | | **Configuration** | Color, verbosity | ✅ Compile-time feature selection + optional runtime | | **Runtime Configuration** | Only verbosity | ✅ Verbosity, color, time, prefix, source location, topics (Disablable feature) | -| **Zero-Overhead Disable** | Args are evaluated | ✅ True no-op with `ULOG_BUILD_DISABLED` | -| **Log Levels** | 6 fixed | 8, runtime renameable (e.g., syslog) | -| **Filtering** | Global + per-callback | Per-output + per-topic + global | +| **Zero-Overhead Disable** | Arguments still evaluated | ✅ True no-op with `ULOG_BUILD_DISABLED` | +| **Log Levels** | 6 fixed | 8, runtime renameable (e.g., syslog) | +| **Filtering** | Global + per-callback | Per-output + per-topic + global | | **Topics/Subsystems** | Manual prefixes | ✅ Full support with filtering per topic and routing | -| **Output Routing** | All outputs get all logs | ✅ Route topics to specific or all outputs | +| **Output Routing** | All outputs get all logs | ✅ Route topics to specific or all outputs | | **Memory** | Static | ✅ Static or dynamic (user choice) | | **Build Systems** | Manual integration | ✅ CMake, Meson, CPM packages | | **Platform Helpers** | DIY | ✅ FreeRTOS, Zephyr, ThreadX, pthread, Win32 | +**When to choose log.c**: Small projects needing basic logging with minimal setup. +**When to choose microlog**: Embedded systems, multi-subsystem applications, or projects requiring fine-grained control. + ### Key Capabilities Unique to microlog **1. Multi-Dimensional Filtering** - Per-output AND per-topic levels: @@ -217,9 +221,9 @@ ulog_level_set_new_levels(&syslog); **4. Fine-Grained Code Control** - 12+ build flags to strip features: ``` --DULOG_BUILD_SOURCE_LOCATION 0 // Remove file:line --DULOG_BUILD_TIME 0 // Remove timestamps --DULOG_BUILD_COLOR 0 // Remove ANSI codes +-DULOG_BUILD_SOURCE_LOCATION=0 // Remove file:line +-DULOG_BUILD_TIME=0 // Remove timestamps +-DULOG_BUILD_COLOR=0 // Remove ANSI codes ... ``` From f531952dc7b5ca044b705712fec83e746f4db973 Mon Sep 17 00:00:00 2001 From: Andrei Gramakov Date: Fri, 7 Nov 2025 16:39:23 +0100 Subject: [PATCH 3/5] Formatting --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c14c169..72af624 100644 --- a/README.md +++ b/README.md @@ -191,8 +191,10 @@ a minimal build can match log.c's footprint. | **Build Systems** | Manual integration | ✅ CMake, Meson, CPM packages | | **Platform Helpers** | DIY | ✅ FreeRTOS, Zephyr, ThreadX, pthread, Win32 | -**When to choose log.c**: Small projects needing basic logging with minimal setup. -**When to choose microlog**: Embedded systems, multi-subsystem applications, or projects requiring fine-grained control. +TL;DR: + +- **When to choose log.c**: Small projects needing basic logging with minimal setup. +- **When to choose microlog**: Embedded systems, multi-subsystem applications, or projects requiring fine-grained control. ### Key Capabilities Unique to microlog From d8e0aa37299cd50cd13eb00a04f536c81f175904 Mon Sep 17 00:00:00 2001 From: Andrei Gramakov Date: Fri, 7 Nov 2025 16:44:26 +0100 Subject: [PATCH 4/5] Improve wording --- README.md | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 72af624..d8f35dd 100644 --- a/README.md +++ b/README.md @@ -17,19 +17,19 @@ In the default configuration it looks like this: -| `` | +| `` | | ------------------------------------------------------------------------------------------------------ | | Picture 1 - default configuration: no time, long default levels, source location, no topics, no colors | ...but in can be very minimalistic : -| `` | +| `` | | ---------------------------------------------------------------- | | Picture 2 - short levels, no colors, no time, no source location | ... or feature-rich: -| `` | +| `` | | ------------------------------------------------------------------------------------------------ | | Picture 3 - time, custom prefix for MsgID, custom syslog levels, topics, source location, colors | @@ -169,32 +169,34 @@ Contributions are welcome! Please read the [CONTRIBUTING.md](CONTRIBUTING.md) fo ## Comparison with log.c -microlog started as a fork of [rxi/log.c](https://github.com/rxi/log.c) (~150 lines, 3.3k stars) but evolved into a fundamentally different architecture (~2,500 lines) optimized for embedded systems and advanced filtering. microlog's larger codebase is offset by compile-time feature stripping - -a minimal build can match log.c's footprint. +microlog started as a fork of [rxi/log.c](https://github.com/rxi/log.c) (~150 lines, 3.3k stars) but evolved into a fundamentally different architecture (~2,500 lines) optimized for embedded systems and advanced filtering. Thanks to compile-time feature stripping, unused features are excluded from the build—so a minimal microlog configuration can match log.c’s footprint in both size and performance. ### Core Differences **rxi/log.c**: Minimalist and ready to use. Fixed footprint, 6 levels, simple callbacks. **microlog**: Compile-time feature selection. Configurable footprint, 8 renameable levels, multi-dimensional filtering. -| Feature | log.c | microlog | -| ------------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------- | -| **Philosophy** | Simple-to-use, Minimalist for average use | Simple-to-use, extensible and configurable for diverse needs | +| Feature | log.c | microlog | +| ------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------ | +| **Philosophy** | Simple-to-use, Minimalist for average use | Simple-to-use, extensible and configurable for diverse needs | | **Configuration** | Color, verbosity | ✅ Compile-time feature selection + optional runtime | | **Runtime Configuration** | Only verbosity | ✅ Verbosity, color, time, prefix, source location, topics (Disablable feature) | -| **Zero-Overhead Disable** | Arguments still evaluated | ✅ True no-op with `ULOG_BUILD_DISABLED` | -| **Log Levels** | 6 fixed | 8, runtime renameable (e.g., syslog) | -| **Filtering** | Global + per-callback | Per-output + per-topic + global | +| **Zero-Overhead Disable** | Arguments still evaluated | ✅ True no-op with `ULOG_BUILD_DISABLED` | +| **Log Levels** | 6 fixed | 8, runtime renameable (e.g., syslog) | +| **Filtering** | Global + per-callback | Per-output + per-topic + global | | **Topics/Subsystems** | Manual prefixes | ✅ Full support with filtering per topic and routing | -| **Output Routing** | All outputs get all logs | ✅ Route topics to specific or all outputs | +| **Output Routing** | All outputs get all logs | ✅ Route topics to specific or all outputs | | **Memory** | Static | ✅ Static or dynamic (user choice) | | **Build Systems** | Manual integration | ✅ CMake, Meson, CPM packages | | **Platform Helpers** | DIY | ✅ FreeRTOS, Zephyr, ThreadX, pthread, Win32 | TL;DR: -- **When to choose log.c**: Small projects needing basic logging with minimal setup. -- **When to choose microlog**: Embedded systems, multi-subsystem applications, or projects requiring fine-grained control. +- **When to choose log.c**: + - Small projects needing basic logging with minimal setup. +- **When to choose microlog**: + - Same scenarios, as default setup is just as simple. + - Plus: embedded systems, multi-subsystem applications, or projects requiring fine-grained control and advanced filtering. ### Key Capabilities Unique to microlog From 8d793135def5a9dd43f69a53750970fe3fa24662 Mon Sep 17 00:00:00 2001 From: Andrei Gramakov Date: Fri, 7 Nov 2025 16:47:26 +0100 Subject: [PATCH 5/5] Fix pictures --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d8f35dd..af40ec2 100644 --- a/README.md +++ b/README.md @@ -17,21 +17,21 @@ In the default configuration it looks like this: -| `` | -| ------------------------------------------------------------------------------------------------------ | -| Picture 1 - default configuration: no time, long default levels, source location, no topics, no colors | +|| +|-| +|Picture 1 - default configuration: no time, long default levels, source location, no topics, no colors| ...but in can be very minimalistic : -| `` | -| ---------------------------------------------------------------- | -| Picture 2 - short levels, no colors, no time, no source location | +|| +|-| +|Picture 2 - short levels, no colors, no time, no source location| ... or feature-rich: -| `` | -| ------------------------------------------------------------------------------------------------ | -| Picture 3 - time, custom prefix for MsgID, custom syslog levels, topics, source location, colors | +| | +|-| +|Picture 3 - time, custom prefix for MsgID, custom syslog levels, topics, source location, colors| The project is based on the following core principles: