gitmyhub

EasyLogger

C ★ 4.7k updated 1y ago

An ultra-lightweight(ROM<1.6K, RAM<0.3k), high-performance C/C++ log library. | 一款超轻量级(ROM<1.6K, RAM<0.3k)、高性能的 C/C++ 日志库

A tiny C and C++ logging library for microcontrollers and IoT devices, using under 1.6KB of storage and 0.3KB of RAM, with 6 severity levels, color-coded terminal output, tag-based filtering, and pluggable log destinations.

CC++setup: moderatecomplexity 2/5

EasyLogger is a tiny C and C++ logging library built for devices where memory is tight, such as IoT sensors, wearables, and smart home hardware. It uses less than 1.6 kilobytes of program storage and less than 0.3 kilobytes of working memory at runtime, making it practical for microcontrollers that have very little space to spare.

The library records messages at six severity levels, following a scale similar to Android's logging system: Assert, Error, Warn, Info, Debug, and Verbose. Each level gets its own color in terminal output, so a developer can visually scan a log quickly. Messages can include timestamps, thread information, file paths, line numbers, and method names, and the format for each severity level can be set independently.

Filtering is built in. A developer can narrow the visible log output by severity level, by a tag they attach to a group of messages, or by a keyword search. This makes it easier to find relevant entries in a busy stream of output. Logging can also be turned on or off dynamically while the program is running, not just at compile time.

For where logs go, EasyLogger lets the developer plug in any destination through a simple porting interface. The core library covers terminal output. Optional plugins handle writing to files with automatic rotation and saving directly to Flash memory without needing a file system, which matters for small embedded devices. Asynchronous output is available so that logging does not slow down the main program on platforms with slow output channels.

The README and all documentation are written in Chinese. The library supports several operating systems including RT-Thread, UCOS, Linux, Windows, and Nuttx, and also works on bare-metal platforms with no operating system. It is released under the MIT license.

Where it fits