A versatile and extensible logging implementation.

Overview

Logforth Project

Crates.io Documentation MSRV 1.75 Apache 2.0 licensed Build Status

Overview

A versatile and extensible logging implementation.

Usage

Add the dependencies to your Cargo.toml with:

cargo add log
cargo add logforth

... where log is the logging facade and logforth is the logging implementation.

Then, you can use the logger with:

use log::LevelFilter;
use logforth::append;
use logforth::layout::TextLayout;
use logforth::Dispatch;
use logforth::Logger;

fn main() {
    Logger::new().dispatch(
        Dispatch::new()
            .filter(LevelFilter::Trace)
            .append(append::Stdout::default()),
        )
        .apply()
        .unwrap();

    log::error!("Hello error!");
    log::warn!("Hello warn!");
    log::info!("Hello info!");
    log::debug!("Hello debug!");
    log::trace!("Hello trace!");
}

Read more demos under the examples directory.

Documentation

Read the online documents at https://docs.rs/logforth.

Supported Rust Versions (MSRV 1.75)

Logforth is built against the latest stable release. The minimum supported version is 1.75. The current Logforth version is not guaranteed to build on Rust versions earlier than the minimum supported version.

When to release a 1.0 version

After one year of practicing the interfaces, if there are no further blockers, I'll release a 1.0 version. So consequently, it can be as early as 2025-08.

License and Origin

This project is licensed under Apache License, Version 2.0.

The name Logforth comes from an antonym to the Logback project.

Comments
  • refactor: use jiff for timestamp

    refactor: use jiff for timestamp

    This closes https://github.com/cratesland/logforth/issues/35.

    @1996fanrui if you'd like to implement something more flexible like Logback's and Log4j's PatternLayout, you can try to follow #7.

    opened by tisonkun 5
  • chore: optimize the magic number to Option and extract common code

    chore: optimize the magic number to Option and extract common code

    Changes:

    • Refactor the type of rolling.State#next_date from usize to Option<usize>
      • rolling.State#next_date is 0 when rotation is Rotation::Never.
      • Using Option compared to magic number can intuitively tell developer that next_date is not effective.
    • Move date.unix_timestamp() as usize inside of next_date
      • All callers of Rotation#next_date convert the data to timestamp, we can convert it inside of Rotation#next_date
      • Also, Rotation#next_date needs to rename to Rotation#next_date_timestamp
    opened by 1996fanrui 4
  • PatternLayout

    PatternLayout

    Something like https://logging.apache.org/log4j/2.x/manual/layouts.html#PatternLayout.

    But we should not reimplement a tribal format. Instead, we can try to leverage tera, mini_jinja or other template libraries.

    enhancement help wanted 
    opened by tisonkun 4
  • Support TimeZone

    Support TimeZone

    As the follwing picture shown, I'm in UTC+8 TimeZone, but all time are shown by UTC+0 TimeZone, it includes:

    • RollingFile name
    • The time format of JsonLayout in RollingFile
    • The time format of TextLayout in Stdout

    And I'm willing to contribute it to support TimeZone.

    I could provide 2 solutions, and I'm not sure which one is better in the long term:

    1. Don't support user set the TimeZone, and we use the default TimeZone of server
    2. Using the default TimeZone of server by default, and user could set it (the default TimeZone will be overwrited)
    img
    opened by 1996fanrui 3
  • LogLevelModuleFilter

    LogLevelModuleFilter

    Something like fern's level_for - https://docs.rs/fern/latest/fern/struct.Dispatch.html#method.level_for

    It should be easy to implement by extending the code of LogLevelFilter with a module field.

    enhancement help wanted good first issue 
    opened by tisonkun 3
  • refactor: layouts and encoders should be nested to appenders

    refactor: layouts and encoders should be nested to appenders

    Follow https://logback.qos.ch/manual/encoders.html and somehow reduce the strange default_layout things.

    Some appender just never receive a custom layout (FastraceEvent) while others would always only meaning with a layout (Stdout/Stderr/...)

    What do you think @andylokandy ?

    opened by tisonkun 1
  • feat: revert to short filename for TextLayout

    feat: revert to short filename for TextLayout

    JsonLayout can still log the full file path since it's mainly for machine read and it's easy to extract the filename during the process.

    TextLayout is mainly for human reading so module name + filename should be enough and the full file path is noisy.

    opened by tisonkun 1
  • test: add unit tests for rolling file

    test: add unit tests for rolling file

    close #34

    Changes:

    • refactor: move Rotation into one separate module and add test for it
      • The rolling file has too many code, so move Rotation into one separate module
    • test: add unit tests for rolling file
      • Introduce the Clock related code to test time rotation
    opened by 1996fanrui 1
  • Optimize the performance of Zoned::now with time zone

    Optimize the performance of Zoned::now with time zone

    As I mentioned in https://github.com/BurntSushi/jiff/issues/93, the performance of Zoned::now().with_time_zone(tz), is much worse than Zoned::new(Timestamp::now(), time_zone).

    When testing locally, performance can be twice as bad, because the Zoned::now().with_time_zone(tz), needs build 2 Zoned instances.

    And Timestamp::now().to_zoned(time_zone) is similar with Zoned::new(Timestamp::now(), time_zone). So their performance are same.

    opened by 1996fanrui 0
Owner
FastLabs
We develop fast Rust crates and release them fast.
FastLabs
A versatile and dynamic music bot designed to elevate the musical experience within Discord servers.

Masayoshi Masayoshi is a discord music bot written in Rust for making a great experience within Discord servers with support to Youtube, SoundCloud, S

null 6 Dec 26, 2023
Rust API Server: A versatile template for building RESTful interfaces, designed for simplicity in setup and configuration using the Rust programming language.

RUST API SERVER Introduction Welcome to the Rust API Server! This server provides a simple REST interface for your applications. This README will guid

Harry Nguyen 3 Feb 25, 2024
tpp (Tera Pre-Processor) is a versatile CLI (Command Line Interface) tool crafted for preprocessing files using the Tera templating engine.

tpp (Tera Pre-Processor) is a versatile CLI (Command Line Interface) tool crafted for preprocessing files using the Tera templating engine. Drawing inspiration from pre-processors like cpp and gpp, tpp is the next evolution with its powerful expressive toolset.

null 3 Nov 23, 2023
Application microframework with command-line option parsing, configuration, error handling, logging, and shell interactions

Abscissa is a microframework for building Rust applications (either CLI tools or network/web services), aiming to provide a large number of features w

iqlusion 524 Dec 26, 2022
✨ sleek typing tui with visualized results and historical logging

thokr ✨ sleek typing tui with visualized results and historical logging Usage For detailed usage run thokr -h. thokr 0.4.1 sleek typing tui with visua

colby thomas 440 Dec 30, 2022
A beautiful, tiny traceback and logging library supporting #![no_std] rust.

breadcrumbs Breadcrumbs is a beautiful, tiny traceback and logging library for Rust that offers seamless integration with #![no_std], multi-threading

Michael 18 Nov 21, 2023
Logging for text that should stay in the same place in a console.

console_static_text Crate for logging text that should stay in the same place in a console. This measures words to handle wrapping and has some consol

David Sherret 8 Dec 25, 2022
A super simple but lightweight logging library that tries to capture the most important (status) information.

Hackerlog A super simple but lightweight logging library that tries to capture the most important (status) information. The following is supported: Lo

434b 3 Aug 22, 2023
An extremely high performance logging system for clients (iOS, Android, Desktop), written in Rust.

Pinenut Log 中文文档 ・ English An extremely high performance logging system for clients (iOS, Android, Desktop), written in Rust. Overview Compression Pin

Tangent 4 Dec 1, 2023
skyWM is an extensible tiling window manager written in Rust. skyWM has a clear and distinct focus adhering to the KISS and Unix philosophy.

Please note: skyWM is currently in heavy development and is not usable as of yet. Documentation and versions will change quickly. skyWM skyWM is an ex

MrBeeBenson 74 Dec 28, 2022
Maccha is an extremely extensible and themable power menu for Windows, macOS, and Linux.

Maccha I hate coffee. Maccha is an extremely extensible and themable power menu for Windows, macOS, and Linux. Plugins Plugins are written in Rust (ot

Kyza 9 May 13, 2023
A simple, lightweight and extensible command line argument parser for rust codebases

A simple, lightweight and extensible command line argument parser for rust codebases. This crate aims to provide you with an easy-to-use and extensibl

Victor Ndaba 20 Nov 12, 2022
Lightweight alternative Discord client with a smaller footprint and some fancy extensible features.

Dorion Dorion is an alternative Discord client aimed and lower-spec or storage-sensitive PCs that supports themes, plugins, and more! Table of Content

SpikeHD 20 Jan 2, 2023
Dreamer is an extensible tool manager and shell for creating small, lightweight, dev environments instantly.

Dreamer ?? Does what you want, not what you say. Dreamer is a universal tool management system for any language, any build system, and any framework.

Luke Davis 4 Oct 23, 2023
Configurable, extensible, interactive line reader

linefeed linefeed is a configurable, concurrent, extensible, interactive input reader for Unix terminals and Windows console. API Documentation linefe

Murarth 176 Jan 3, 2023
Simple, extensible multithreaded background job processing library for Rust.

Apalis Apalis is a simple, extensible multithreaded background job processing library for Rust. Features Simple and predictable job handling model. Jo

null 50 Jan 2, 2023
An extensible plotting library for CLI applications.

termplot An extensible plotting library for CLI applications. Quick Start Documentation Examples Plotting a function Historigram Composing multiple pl

Xavier Hamel 3 Jan 1, 2023
A fully extensible command interface to navigate around your leptos application.

leptos-kbar A fully extensible command interface to navigate around your leptos application. See demo: https://leptos-kbar.vercel.app/ Roadmap leptos-

null 7 Mar 10, 2024
A SIMD implementation of Keccak256 for aarch64, forked from Remco Bloeman's Goldilocks K12 implementation.

keccak256-aarch64 Warning This crate was forked from real cryptographers (Goldilocks by Remco Bloeman), by not a real cryptographer. Do not use this k

null 6 Oct 24, 2023