Ultra-lightweight, high-performance C-Log library--easylogger

Source: Internet
Author: User

EasyLogger1. Introduced

Easylogger is an ultra-lightweight (rom<1.6k, ram<0.3k), high-performance C-Log library that is ideal for resource-sensitive software projects such as IoT products, wearables, smart homes, and more. Compared to log4c, Zlog, these well-known C-log libraries, Easylogger's functionality is simpler, providing users with fewer interfaces, but getting started quickly and more practical features support dynamic expansion in plug-in form.

1.1 Main Features
    • Support user-defined output mode (for example: terminal, file, database, serial port, 485, Flash ...) );
    • Log content can contain level, timestamp, thread information, process information, etc.;
    • The log output is designed in a thread-safe manner;
    • Supports multiple operating systems (Rt-thread, UCOS, Linux, Windows ... ), also support bare metal platforms;
    • The log supports RAW format ;
    • Support by tags , levels , keywords to dynamically filter;
    • Strong extensibility to support the expansion of new features in plug-in form.

Noun Explanation:
1. Raw format: original log without formatting.
2, Tags: in the software can be in accordance with files, modules, functions and other aspects, the need to print the log set tags, to achieve the classification of logs.

1.2 Plugins
    • 1, Flash: Using the Flash operation interface provided by the Easyflash library, the log can be stored directly in Flash.
    • 2, file (under development): Support file transfer, software runtime dynamic load configuration file and other functions related to file log output.
    • 3. Please look forward to ...
1.3 Star & Fork

I will also provide more plugins later. We also welcome you to design, develop more practical plug-ins and functions, together to improve the Easylogger (github| oschina| Coding) . If you think this open source project is great, click Starin the top right corner of the project homepage and recommend it to more friends in need.

2. Using the 2.1 parameter configuration

Easylogger has filters, output formats, and output switches for these properties.

    • Filtering mode supports filtering according to tags, levels, keywords;
    • The output of the log can be turned on/off dynamically;
    • Dynamic and static output levels can be set (static: first-level switches, defined by macros; dynamic: Two-level switch via API interface).

Note: The current parameter configuration and output mode are single-case mode, that is, the global only one configuration method is supported. In this mode, the software is simpler, but it cannot support complex output methods.

2.2 Output levels

Refer to Android Logcat, with a level of up to 0 (Assert) and a minimum of 5 (Verbose).

0.[A]:断言(Assert)1.[E]:错误(Error)2.[W]:警告(Warn)3.[I]:信息(Info)4.[D]:调试(Debug)5.[V]:详细(Verbose)
2.3 Output filtering

Supports filtering by levels, tags, and keywords . When the log content is more, the filter function can be used to locate the log faster and ensure the readability of the log. For more information on how to set the filter, please read the \docs\zh\api\kernel.md documentation

2.4 Output format

Output format support: level, time, label, process information, thread information, file path, line number, method name. Each priority level can be set independently of the output format.

Note: The default is raw format, the RAW format log does not support label filtering

2.5 Output Mode

With the user's porting, you can support any type of output. But for some kind of output may introduce new features, need to be implemented through plug-ins, such as: File dump, retrieve flash logs and so on. Later, there will be more plug-ins open source out. Below is a simple comparison of the partial output mode usage scenario:

    • Terminal: Convenient for users to view dynamically, do not have storage function;
    • Files and Flash: both have storage capabilities, and users can view history logs. However, the file mode requires file system support, and the Flash method is more suitable for small embedded devices without file system.
2.6 Demo2.6.1 Core functions

In order to enter commands in terminal to control the output of the log and the settings of the filter, the Easylogger core function is displayed more intuitively.

    • Demo Path:\demo\os\rt-thread\stm32f10x\
    • API Documentation:\docs\zh\api\kernel.md
    • Porting Documents:\docs\zh\port\kernel.md

2.6.2 Flash log (saves the log to Flash)

The process is to output logs through the console and store the output logs in Flash. Restart to read the last saved log, and finally empty the flash log.

    • Demo Path:\demo\os\rt-thread\stm32f10x\
    • API Documentation:\docs\zh\api\flash.md
    • Porting Documents:\docs\zh\port\flash.md

3. Documentation

Refer \docs\zh\ to the file under specific content. It is important to ensure that you read the document before porting it.

4. Late
    • 1,Flash storage: In the Easyflash to increase the log storage, read function, so that Easylogger and its seamless docking. So that the log can be stored more easily in the non-file system , and has the function of historical day retrieval;
    • 2, configuration file: File system under the configuration file;
    • 3, File transfer: File system supporting files according to the capacity of the shift, according to the time division;
    • 4, log Assistant: Development of cross-platform log assistant, compatible with Linux, Windows, Mac system, open Assistant to view, filter (support regular expression), sorting, save the log and so on. Front End: HTML5 + Bootstrap + AngularJS + nw.js, back end: Rust + iron + Rust-websocket + serial-rs;
    • 5, asynchronous output: The current log output and user code is synchronized between the way, although the software is simple, there is no issue of log coverage. However, under the platform with low output speed, the speed of software operation can be reduced due to the increase of log function. So the latter will increase the asynchronous output mode, keyword filtering can also be put into the asynchronous output;
    • 6, Arduino: Add Arduino lib, and provide its demo;
5. License

MIT Copyright (c) [email protected]

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Ultra-lightweight, high-performance C-Log library--easylogger

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.