EasyLogger
1. Introduction
EasyLogger is an ultra-lightweight (ROM< 1.6K, RAM < 0.3K), high-performance C log library, ideal for resource-sensitive software projects, such as: iot products, wearable devices, smart home and more. Compared with log4C, Zlog, the well-known C log library, easyLogger has simpler functions and provides fewer interfaces to users, but it can be used quickly. More practical functions support dynamic expansion in the form of plug-ins. <=”” p=””>
1.1 Main Features
- Supports user-defined output modes (for example, terminal, file, database, serial port, 485, Flash…) ;
- The log content includes the level, time stamp, thread information, and process information.
- Logging is designed to be thread-safe;
- Supports multiple operating systems (RT-Thread, UCOS, Linux, Windows…) , also supports bare platform;
- Logs support RAW format.
- Supports dynamic filtering by label, level, and keyword.
- Strong expansibility, support to extend new functions in the form of plug-ins.
RAW: RAW logs that have not been formatted. 2. Label: In the software, labels can be set for logs to be printed according to files, modules, functions and other aspects to achieve log classification.
1.2 plug-in
- 1. Flash: Using the Flash operation interface provided by EasyFlash library, you can store the log directly in Flash.
- 2. File (under development) : support File transfer, dynamic loading of configuration files while software is running and other functions related to File log output.
- 3. Stay tuned for…
1.3 Star & Fork
There will be more plug-ins to come. Also very welcome to design, develop more practical function plug-ins and, to complete together EasyLogger (making | OSChina | Coding). If you think this open source project is great, you can click the Star in the upper right corner of the project homepage and recommend it to more friends who need it.
2. Use
2.1 Parameter Configuration
EasyLogger has properties such as filter mode, output format and output switch.
- Filter mode You can filter by label, level, and keyword.
- Log output can be dynamically enabled/disabled.
- Dynamic and static output levels can be set (static: one level switch, defined by macro; Dynamic: secondary switch, through API interface).
Note: Currently, parameter configuration and output mode are singleton mode, that is, only one configuration mode is supported globally. In this mode, the software is simpler, but cannot support complex output methods.
2.2 Output Levels
See Android Logcat. The highest level is 0(Assert) and the lowest level is 5(Verbose).
0. [A] : assertions (Assert) 1. [E] : Error (Error) 2. [W] : warning (Warn) 3. [I] : information (Info) 4. [D] : Debug (Debug) 5. [V] : detailed (Verbose)Copy the code
2.3 Output Filtering
Supports filtering by level, label, and keyword. If there are too many logs, you can use the filtering function to locate logs quickly and ensure the readability of logs. For more details on how to set up the filtering function, please read the document \docs\zh\ API \kernel.md
2.4 Output Format
Output format: level, time, label, process information, thread information, file path, line number, method name. Each priority level can set the output format independently.
Note: The default log format is RAW. Logs in RAW format do not support label filtering
2.5 Output Mode
Any output mode can be supported by user portability. However, for certain output methods may introduce new functions, need to be implemented through plug-ins, such as: file transfer, Flash log retrieval and so on. There will be more open source plugins in the future. The following is a simple comparison of the usage scenarios of some output modes:
- Terminal: convenient user dynamic view, do not have storage function;
- Files and Flash: Both have the storage function, and users can view historical logs. However, the file mode needs the support of the file system, and Flash mode is more suitable for small embedded devices without file system.
2.6 the Demo
2.6.1 Core Functions
The following figure shows the core functions of EasyLogger more intuitively by inputting commands in the terminal to control the output of logs and the setting of filters.
2.6.2 Flash Log (Saving Logs in a Flash)
The following figure shows the process of outputting logs through the console and storing the output logs in Flash. Restart, read the logs saved last time, and delete the Flash logs.
3. Document
For details, please refer to the document \docs\zh\. Be sure to read the documentation before porting it.
The late 4.
- 1.
Flash storage: inEasyFlashAdd log storage, reading function, so that the EasyLogger and seamless docking. Make logging easier to store inNon-file system,It also has the function of historical day retrieval. - 2. Configuration file: configuration file in the file system.
- 3. File transfer: The file system supports file transfer by capacity and time.
- 4. Log Assistant: develop cross-platform log assistant, compatible with Linux, Windows and Mac systems. Open the assistant to view, filter (support regular expression), sort, save logs and so on. Front-end: HTML5 + Bootstrap + AngularJS + nw.js; back-end: Rust + Iron + rust-websocket + serial-RS;
- 5. Asynchronous output: at present, log output and user code are synchronized. Although this method is simple in software, there is no log coverage problem. However, on the platform with low output speed, the software running speed will be reduced due to the addition of log function. So the later will increase the asynchronous output, keyword filtering can also be put in the asynchronous output;
- 6. Arduino: Add Arduino lib and provide its Demo;
5. The license
MIT Copyright (c) [email protected]