How armink/easylogger works
Project type and purpose
• This is an open-source, embeddable C/C++ logging library (EasyLogger) designed for resource-constrained systems (bare-metal, RTOS, Linux, Windows, Nuttx).
• It provides a minimal API, plugin-based extensibility (file, flash, etc.), and OS-abstraction ports for thread safety and asynchronous output.
File structure
• Top level:
• easylogger/ ← core library source & headers
• demo/ ← per-OS and bare-metal example applications
• os/ ← porting layers & demo code for various OSes (RT-Thread, FreeRTOS, Linux, Windows, Nuttx)
• docs/ ← user API, porting guides, images
• README.md ← overall project description
• Patterns:
• Layered: core library → plugin folder → port folder → demo/app
• Plugin architecture: easylogger/plugins/*
• Port abstraction: elog_port.c under each OS directory
• Singleton/config module in elog_cfg.h
Key README insights
• Core features: customizable output, filtering, async/buffered mode, multi-OS support, RAW/hexdump formats.
• Plugins: Flash (EasyFlash integration), File (cycle/split), future plugins.
• Demos show CLI control, flash storage, file logging.
• Application layer (demo apps, user code)
• EasyLogger API (public headers)
• Core engine modules:
– Configuration & filtering
– Formatter (timestamp, level, tag)
– Output manager (sync/async, buffer)
– Utilities (hexdump, utils)
• Plugin modules:
– File plugin
– Flash plugin
– (others via plugin interface)
• Port/Hardware Abstraction Layer:
– elog_port implementations per OS
– HAL libraries (CMSIS, STM32 StdPeriph, HAL driver)
• OS / Runtime environments:
– Bare-metal
– FreeRTOS
– RT-Thread
– Linux
– Windows
– Nuttx
• App → EasyLogger API calls (elog_init, elog_flush, elog_set_level)
• API → Core engine (dispatch, filter, format)
• Core engine → Plugin interface (register, invoke)
• Plugin → Port HAL (elog_port_write)
• Port HAL → OS/HAL drivers → hardware (UART, file system, flash)
• Core engine using async buffer may spawn RTOS tasks or IRQ callbacks
c. Architectural patterns & principles:
• Layered architecture (Separation of concerns)
• Plugin/Strategy pattern for extensibility
• Singleton for global config
• Adapter pattern in port layer to unify OS/hardware calls
• Thread-safe queue for async logging
d. Relevant technologies & libraries:
• C/C++ ANSI code (easylogger/src, inc)
• CMSIS, STM32 HAL or StdPeriph (for embedded targets)
• FreeRTOS, RT-Thread kernels (port demos)
• POSIX APIs (Linux demo)
• Win32 APIs (Windows demo)
• Nuttx build system/apps
Detailed elements
• Component names (e.g., elog.c, elog_async.c, elog_port.c) or logical names (Config, Formatter, Output Manager)
• Plugin entry points (e.g., elog_file_port.c, elog_flash_port.c)
• I/O endpoints (UART, file system, Flash memory)
• Build artifacts if relevant (Makefile, CMakeLists.txt, IDE projects)