Giter Site home page Giter Site logo

l0g's Introduction

l0g

Opinionated l0gging facade meant for the no_std libraries that are also sometimes used in a std context.

Overview

Logging facilities differ depending on the environment, especially between no_std and std. This facade allows to delegate the decision which l0gging implementation shall be used to the top-level application.

Any call to l0g::{error,warn,info,debug,trace} turns into a

  • noop when no feature is set
  • log::{error,warn,info,debug,trace} from the log crate when log feature is set
  • defmt::{error,warn,info,debug,trace} from the defmt crate when defmt feature is set

Moreover, proc-macro is provided to generalize over which formatting implementation should be used

#[l0g::format]
struct MyStruct {
    value: u8
}

turns into

#[derive(core::fmt::Debug)]
struct MyStruct {
    value: u8
}

if log feature is used or

#[derive(defmt::Format)]
struct MyStruct {
    value: u8
}

if defmt feature is used.

This allows a {:?} formatting to work, regardless of which logging implementation is chosen.

Usage

In the Cargo.toml of your libraries just say

l0g = "1"

In the no_std top-level application specify the dependency with the defmt feature. For how to make defmt work, take a look into its respective documentation.

l0g = { version = "1", features = ["defmt"] }

In the std top-level application specify the dependency with the log feature. For how to make log work, take a look into its respective documentation.

l0g = { version = "1", features = ["log"] }

l0g's People

Contributors

glaeqen avatar

Watchers

 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.