{"id":33622136,"url":"https://github.com/an-dr/microlog","last_synced_at":"2026-02-22T13:22:11.429Z","repository":{"id":159534470,"uuid":"316789348","full_name":"an-dr/microlog","owner":"an-dr","description":"A lightweight, universal logging library in C. Just two files. Compatible with C++, embedded projects, and most major compilers. Covered by unit tests.","archived":false,"fork":false,"pushed_at":"2025-12-01T19:55:02.000Z","size":796,"stargazers_count":125,"open_issues_count":12,"forks_count":14,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-12-04T05:33:56.011Z","etag":null,"topics":["log","logger","logging","logging-library"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"rxi/log.c","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/an-dr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2020-11-28T17:44:45.000Z","updated_at":"2025-12-02T14:36:12.000Z","dependencies_parsed_at":"2024-11-28T19:25:43.677Z","dependency_job_id":"fe0661f4-38c8-42e3-b6e8-0fe8e879c806","html_url":"https://github.com/an-dr/microlog","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"purl":"pkg:github/an-dr/microlog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/an-dr%2Fmicrolog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/an-dr%2Fmicrolog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/an-dr%2Fmicrolog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/an-dr%2Fmicrolog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/an-dr","download_url":"https://codeload.github.com/an-dr/microlog/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/an-dr%2Fmicrolog/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27545490,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-06T02:00:06.463Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["log","logger","logging","logging-library"],"created_at":"2025-12-01T17:00:22.688Z","updated_at":"2025-12-06T15:01:11.555Z","avatar_url":"https://github.com/an-dr.png","language":"C","funding_links":[],"categories":["Utilities"],"sub_categories":["YAML"],"readme":"# microlog - Extensible and configurable logging library for embedded and desktop applications\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Latest](https://img.shields.io/github/v/tag/an-dr/microlog?style=flat\u0026filter=v*\u0026label=Release)](https://github.com/an-dr/microlog/tags)\n[![Tests](https://github.com/an-dr/microlog/actions/workflows/workflow-tests.yml/badge.svg?branch=main)](https://github.com/an-dr/microlog/actions/workflows/workflow-tests.yml)\n\n![main_pic](doc/README/diagram.drawio.svg)\n\n- **Easy to use** - simple API, works out of the box\n- **Advanced filtering** and log levels per **topic** or **output**\n- **Thread-safety** via external locking injection\n- **Customization** - only data you need\n- **Extensible** - add your own features via public API, set of predefined extensions\n- **Support for embedded systems** static allocation, small size\n- **Easy to install** two files for copy-paste and support for many build systems\n- **For everyone** - C and C++ support, works with any compiler, any platform, commercial or open-source use\n\nIn the default configuration it looks like this:\n\n|\u003cimg src=\"doc/README/demo0.png\" width=\"800\"\u003e|\n|-|\n|Picture 1 - default configuration: no time, long default levels, source location, no topics, no colors|\n\n...but in can be very minimalistic :\n\n|\u003cimg src=\"doc/README/demo1.png\" width=\"800\"\u003e|\n|-|\n|Picture 2 - short levels, no colors, no time, no source location|\n\n... or feature-rich:\n\n|\u003cimg src=\"doc/README/demo2.png\" width=\"800\"\u003e |\n|-|\n|Picture 3 - time, custom prefix for MsgID, custom syslog levels, topics, source location, colors|\n\nThe project is based on the following core principles:\n\n- Universal for embedded and desktop applications\n- No feature - no code for compilation\n- Shallow learning curve, works out of box\n- No dependencies\n- Two files for core functionality.\n- Extensions as recipes for your own features.\n\n## Table of Contents\n\n- [microlog - Extensible and configurable logging library for embedded and desktop applications](#microlog---extensible-and-configurable-logging-library-for-embedded-and-desktop-applications)\n    - [Table of Contents](#table-of-contents)\n    - [Quick Start](#quick-start)\n        - [1. Install](#1-install)\n        - [2. Use](#2-use)\n        - [3. Extend](#3-extend)\n    - [Advanced Usage](#advanced-usage)\n    - [Contributing](#contributing)\n    - [Comparison with log.c](#comparison-with-logc)\n        - [Core Differences](#core-differences)\n        - [Key Capabilities Unique to microlog](#key-capabilities-unique-to-microlog)\n    - [Changelog](#changelog)\n    - [License](#license)\n    - [Credits](#credits)\n\n## Quick Start\n\n### 1. Install\n\n**Option 1 - Sources**:\n\n- Download a Source Package from [Releases](https://github.com/an-dr/microlog/releases)\n- Add sources to your system manually\n\n**Option 2 - CMake Package (recommended CMake \u003e 3.15.0)**:\n\n- Download a CMake Package from [Releases](https://github.com/an-dr/microlog/releases)\n- Specify the install location:\n  - Specify package storage `cmake -B./build -DCMAKE_PREFIX_PATH=\"~/MyCmakePackages\"` or\n  - Set `microlog_DIR` variable with path to the package `microlog_DIR=~/microlog-1.2.3-cmake`\n- Use in your project:\n\n```cmake\nfind_package(microlog 1.2.3 REQUIRED)\n\nadd_executable(example_package example.cpp)\ntarget_link_libraries(example_package PRIVATE microlog::microlog)\n\ntarget_compile_definitions(microlog PRIVATE ULOG_BUILD_COLOR=1) # configuration\n\n# Or use a user-defined configuration header `ulog_config.h`:\n# target_compile_definitions(microlog PRIVATE ULOG_BUILD_CONFIG_HEADER_ENABLED=1)\n# target_include_directories(microlog PRIVATE path/to/directory/containing/ulog_config.h)\n```\n\n**Option 3 - Meson Package**:\n\n- Download a Meson Package from [Releases](https://github.com/an-dr/microlog/releases)\n- Copy the content to `MyMesonProject/subprojects`\n- Add to your dependencies:\n\n```meson\nadd_global_arguments('-DULOG_BUILD_COLOR=1', language: ['cpp', 'c']) # configuration\n\n# Or use a user-defined configuration header `ulog_config.h`:\n# add_global_arguments('-DULOG_BUILD_CONFIG_HEADER_ENABLED=1', language: ['cpp', 'c'])\n# And add include directory where ulog_config.h is located:\n# add_global_arguments('-Ipath/to/directory/containing/ulog_config.h', language: ['cpp', 'c'])\n\nexe = executable(\n    meson.project_name(),\n    src,\n    include_directories: include,\n    dependencies: dependency('microlog'),\n)\n```\n\n**Option 4 - Meson Wrap File**:\n\n- Download the wrap file from [Releases](https://github.com/an-dr/microlog/releases)\n- Place `microlog.wrap` in your `MyMesonProject/subprojects/` directory\n- Add to your dependencies as in Option 3\n\n**Option 5 - CPM:**\n\n- Download CPM (https://github.com/cpm-cmake/CPM.cmake)\n- Add microlog to your projects CMAKE file:\n\n```cmake\ninclude(cpm/CPM.cmake)\nCPMAddPackage(\"gh:an-dr/microlog@6.4.5\")\n\ntarget_link_libraries(${PROJECT_NAME} PUBLIC microlog::microlog)\ntarget_compile_definitions( microlog PRIVATE ULOG_BUILD_COLOR=1) # configuration\n    \n# Or use a user-defined configuration header `ulog_config.h`:\n# target_compile_definitions(microlog PRIVATE ULOG_BUILD_CONFIG_HEADER_ENABLED=1)\n# target_include_directories(microlog PRIVATE path/to/directory/containing/ulog_config.h)\n```\n\n### 2. Use\n\n```cpp\n#include \"ulog.h\"\n\nint main() {\n    ulog_info(\"Hello, World\");\n    return 0;\n}\n```\n\nOutput:\n\n```log\nINFO  src/main.cpp:4: Hello, World\n```\n\n### 3. Extend\n\nAdd missing functionalities via API or use predefined extensions. See [Extensions documentation](extensions/README.md).\n\n## Advanced Usage\n\n[User Manual in `doc/features.md`](doc/features.md) - detailed information about the available features.\n\n[Extensions](extensions/README.md) - Optional add-ons that use only the public API to enhance functionality.\n\n[See the example for more features in action: `example/main.cpp`](example/main.cpp).\n\n## Contributing\n\nContributions are welcome! Please read the [CONTRIBUTING.md](CONTRIBUTING.md) for details, I tried to keep it simple.\n\n## Comparison with log.c\n\nmicrolog 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.\n\n### Core Differences\n\n**rxi/log.c**: Minimalist and ready to use. Fixed footprint, 6 levels, simple callbacks.\n**microlog**: Compile-time feature selection. Configurable footprint, 8 renameable levels, multi-dimensional filtering. \n\n| Feature                   | log.c                                      | microlog                                                                       |\n| ------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------ |\n| **Philosophy**            | Simple-to-use,  Minimalist for average use | Simple-to-use, extensible and configurable for diverse needs                   |\n| **Configuration**         | Color, verbosity                           | ✅ Compile-time feature selection + optional runtime                            |\n| **Runtime Configuration** | Only verbosity                             | ✅ Verbosity, color, time, prefix, source location, topics (Disablable feature) |\n| **Zero-Overhead Disable** | Arguments still evaluated                  | ✅ True no-op with `ULOG_BUILD_DISABLED`                                        |\n| **Log Levels**            | 6 fixed                                    | 8, runtime renameable (e.g., syslog)                                           |\n| **Filtering**             | Global + per-callback                      | Per-output + per-topic + global                                                |\n| **Topics/Subsystems**     | Manual prefixes                            | ✅ Full support with filtering per topic and routing                            |\n| **Output Routing**        | All outputs get all logs                   | ✅ Route topics to specific or all outputs                                      |\n| **Memory**                | Static                                     | ✅ Static or dynamic (user choice)                                              |\n| **Build Systems**         | Manual integration                         | ✅ CMake, Meson, CPM packages                                                   |\n| **Platform Helpers**      | DIY                                        | ✅ FreeRTOS, Zephyr, ThreadX, pthread, Win32                                    |\n\nTL;DR:\n\n- **When to choose log.c**:\n    - Small projects needing basic logging with minimal setup.\n- **When to choose microlog**:\n    - Same scenarios, as default setup is just as simple.\n    - Plus: embedded systems, multi-subsystem applications, or projects requiring fine-grained control and advanced filtering.\n\n### Key Capabilities Unique to microlog\n\n**1. Multi-Dimensional Filtering** - Per-output AND per-topic levels:\n\n```c\nulog_topic_add(\"Credentials\", secure_file_only, ULOG_LEVEL_TRACE);\nulog_topic_add(\"Network\", ULOG_OUTPUT_ALL, ULOG_LEVEL_DEBUG);\nulog_output_level_set(ULOG_OUTPUT_STDOUT, ULOG_LEVEL_ERROR); // Console: errors only\n```\n\n**2. True Zero-Overhead Disable** - Arguments not evaluated:\n\n```c\nulog_info(\"Result: %d\", expensive()); // With ULOG_BUILD_DISABLED=1 → ((void)0)\n```\n\n**3. Custom Log Levels** - Redefine all 8 at runtime:\n\n```c\nulog_level_descriptor syslog = {ULOG_LEVEL_7,\n    {\"DEBUG\", \"INFO\", \"NOTICE\", \"WARN\", \"ERR\", \"CRIT\", \"ALERT\", \"EMERG\"}};\nulog_level_set_new_levels(\u0026syslog);\n```\n\n**4. Fine-Grained Code Control** - 12+ build flags to strip features:\n\n```\n-DULOG_BUILD_SOURCE_LOCATION=0  // Remove file:line\n-DULOG_BUILD_TIME=0              // Remove timestamps\n-DULOG_BUILD_COLOR=0             // Remove ANSI codes\n...\n```\n\n## Changelog\n\nSee [CHANGELOG.md](CHANGELOG.md) for details.\n\n## License\n\nThis library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See [LICENSE](LICENSE) for details.\n\n## Credits\n\nBased on [https://github.com/rxi/log.c.git](https://github.com/rxi/log.c.git)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fan-dr%2Fmicrolog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fan-dr%2Fmicrolog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fan-dr%2Fmicrolog/lists"}