GithubHelp home page GithubHelp logo

justjavac / log Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rust-lang/log

1.0 2.0 0.0 1.12 MB

Logging implementation for Rust

Home Page: https://docs.rs/log

License: Apache License 2.0

Rust 100.00%

log's Introduction

log

A Rust library providing a lightweight logging facade.

Build status Latest version Documentation License

A logging facade provides a single logging API that abstracts over the actual logging implementation. Libraries can use the logging API provided by this crate, and the consumer of those libraries can choose the logging implementation that is most suitable for its use case.

Minimum supported rustc

1.31.0+

This version is explicitly tested in CI and may be bumped in any release as needed. Maintaining compatibility with older compilers is a priority though, so the bar for bumping the minimum supported version is set very high. Any changes to the supported minimum version will be called out in the release notes.

Usage

In libraries

Libraries should link only to the log crate, and use the provided macros to log whatever information will be useful to downstream consumers:

[dependencies]
log = "0.4"
use log::{info, trace, warn};

pub fn shave_the_yak(yak: &mut Yak) {
    trace!("Commencing yak shaving");

    loop {
        match find_a_razor() {
            Ok(razor) => {
                info!("Razor located: {}", razor);
                yak.shave(razor);
                break;
            }
            Err(err) => {
                warn!("Unable to locate a razor: {}, retrying", err);
            }
        }
    }
}

In executables

In order to produce log output, executables have to use a logger implementation compatible with the facade. There are many available implementations to choose from, here are some of the most popular ones:

Executables should choose a logger implementation and initialize it early in the runtime of the program. Logger implementations will typically include a function to do this. Any log messages generated before the logger is initialized will be ignored.

The executable itself may use the log crate to log as well.

log's People

Contributors

aergonaut avatar alexcrichton avatar amanieu avatar andygauge avatar brson avatar budziq avatar carols10cents avatar cowang4 avatar dbrgn avatar dekellum avatar diondokter avatar dtolnay avatar frewsxcv avatar huonw avatar jehiggs avatar jonas-schievink avatar jyn514 avatar kodraus avatar lukazoid avatar markmccaskey avatar mbrubeck avatar morrme avatar nivkner avatar omh1280 avatar sfackler avatar sunfishcode avatar tethyssvensson avatar thomasdezeeuw avatar tmccombs avatar yoshuawuyts avatar

Stargazers

 avatar

Watchers

 avatar  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.