Giter VIP home page Giter VIP logo

mlog's Introduction

MLOG -- A micro logger for constrained systems.

Description

MLOG is a super-efficient logger for constrained systems like small embedded systems -- systems that cannot afford traditional string-based logging.

The idea is simple: instead of space-consuming log strings, 1-byte constants are defined in the code whose symbol name carries the text that is to be logged. For instance:

// Traditional logging:
logger("Inside function foo");

// Micro logging:
MLOG_INFO(Inside_function_foo);

The MLOG_INFO macro once statically allocates a one-byte symbol that looks more or less like this:

static const uint8_t MLOG_Comp_II_Inside_function_foo___;

Whenever execution reaches the MLOG_INFO macro, the address of the symbol is transferred to the log buffer. Later, on the receiving side, the original log string can be reconstructed with the help of the map file, where all MLOG symbols and their corresponding addresses can be found:

Address: Symbol:
------------------------------------------------------------
00656618 MLOG_MlogTest_II_Hello_there___
00656619 MLOG_MlogTest_II_Enter_AdvancedCharSearch___
0065661a MLOG_MlogTest_EE_ENSURE_text_must_not_be_null___
0065661b MLOG_MlogTest_WW_search_char_should_not_be_null___
0065661c MLOG_MlogTest_EE_invalid_search_mode___
0065661d MLOG_MlogTest_II_Exit_AdvancedCharSearch___
:

The benefit of the micro logging approach is clear: with traditional logging, 20 bytes would have to be stored and 20 bytes would have to be transmitted; with micro logging, only 1 byte needs to be stored and only 4 bytes need to be transmitted.

MLOG API

Currently, the following MLOG macros are implemented (refer to mlog_base.h):

  • MLOG_INFO(m) Output text 'm' at log-level INFO.

  • MLOG_WARN(m) Output text 'm' at log-level WARNING.

  • MLOG_ERROR(m) Output text 'm' at log-level ERROR.

  • MLOG_INFO_VALUE(m, v) Output text 'm' and an unsigned value 'v' at log-level INFO.

  • MLOG_WARN_VALUE(m, v) Output text 'm' and an unsigned value 'v' at log-level WARNING.

  • MLOG_ERROR_VALUE(m, v) Output text 'm' and an unsigned value 'v' at log-level ERROR.

  • MLOG_ENSURE(e, m) If expresson 'e' is false, output text 'm'.

Dependencies

For running the provided example: just g++ and python3

If you want to extend/unit test MLOG itself, that is, if you want to run make in the top-level directory, you need Google Test/Google Mock. Please adapt paths in the Makefile accordingly.

Portability

The code for MLOG is highly portable and should compile with any contemporary C/C++ toolchain. generate_mlogmap.sh currently supports extraction of MLOG log symbols from gcc/g++ map files only.

Usage

Have a look at the README.md file in the example/ folder.

mlog's People

Contributors

ralfholly avatar

Stargazers

Oğuzhan Özel avatar Eren ERASLAN avatar  avatar Markus avatar M Ferris avatar Albert Tavares de Almeida avatar Adrian Gielniewski avatar  avatar Fryderyk M. avatar David Kincaid avatar Niklas Tinglöf avatar Alexandre Pereira Nunes avatar jimmyou avatar Chris Hemingway avatar Andreas Olofsson avatar Mark VanderVoord avatar  avatar Michael Leonard avatar Jan Lochmatter avatar Dave Rea avatar Chris Weaver avatar  avatar Caleb Jamison avatar Matt Liberty avatar Dillon avatar Haroldo Amaral avatar Andy Mauragis avatar  avatar

Watchers

Caleb Jamison avatar James Cloos avatar Alexandre Pereira Nunes avatar glc avatar  avatar M Ferris avatar Niklas Tinglöf avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.