A Rust logger with various features.

Related tags

Logging moe-logger
Overview

Moe Logger

(>ω<) Another logger based on pretty-env-logger and env_logger. Allow writing log to file with features like formatting, file rotation.

Usage

Append following lines to Cargo.toml:

log = "0.4"
moe_logger = "0.2"

There's an example:

{M}\n") .rotation(10000) .finish(); moe_logger::init(log_config); info!("Di di ba ba wu~"); debug!("Debug..."); warn!("WARNING!"); error!("Oops >_<"); } ">
use log::{info, warn, error, debug};
use moe_logger::LogConfig;

fn main() {
    let log_config = LogConfig::builder()
        .env("MOE_LOG_LEVEL")
        .output("run.log")
        .format("{t} {L} {T} > {M}\n")
        .rotation(10000)
        .finish();
    moe_logger::init(log_config);

    info!("Di di ba ba wu~");
    debug!("Debug...");
    warn!("WARNING!");
    error!("Oops >_<");
}

Features

(^ω^) Here is some notice about features provided.

Output

If you specify a path to store log, Moe Logger would write formatted log to that path and unformatted log to stdout in the meanwhile.

(;>△<) If log file exists, Moe Logger will only use stdout! So move old logs to another place before running.

Format

We are using TinyTemplate to format content wrote to file. If you are interested in more fancy logs, you may should check its document. Moe Logger provided variables listed below:

  • t - RFC3339 Date & Time
  • L - Log Level
  • T - Log Target
  • M - Log Message
  • F - File Name

Default format: {L} {T} > {M}\n

(;>△<) DO NOT FORGET \n

Rotation

You can specify after how many line written, Moe Logger would rename it like output.log.x. Default 0 for disabled.

Performance

(。・`ω´・)ノ Writing log to disk would worse the efficiency of your code. But we are always trying to optimize this problem. If you have any ideas, pull requests and issues are welcomed.

The table below shows the performance difference when you enable different features. (By running an actix-web back-end on my PC)

Feature Requests per Second
No Log ~16000
Only to Stdout ~15000
Stdout & File ~5600
Stdout & File(with Rotation) ~5200

License

Moe Logger is distributed under the terms of both Apache-2.0 and MIT license.

You might also like...
A highly configurable logging framework for Rust

log4rs log4rs is a highly configurable logging framework modeled after Java's Logback and log4j libraries. Warning If you are using the file rotation

Application level tracing for Rust.

Website | Chat | Documentation (master branch) Overview tracing is a framework for instrumenting Rust programs to collect structured, event-based diag

Task-based logging for rust
Task-based logging for rust

task_log task_log is a task-based logger. Installing Just add task_log = 0.1.4 to your Cargo.toml's dependency section. Example Let's get right to the

💬 A couple of functions to make logging in Rust easier.
💬 A couple of functions to make logging in Rust easier.

Rust logging ⛔ 💬 A couple of functions to make logging in Rust easier. Installation 📦 Just add the code of code.rs to your project. You can copy/pas

A rust library for creating and managing logs of arbitrary binary data

A rust library for creating and managing logs of arbitrary binary data. Presently it's used to collect sensor data. But it should generally be helpful in cases where you need to store timeseries data, in a nearly (but not strictly) append-only fashion.

A cool log library built using rust-lang

RustLog A cool log library built using rust-lang Installation: Cargo.toml rustlog = { git = "https://github.com/krishpranav/rustlog" } log = "0.4.17"

godot-logger is an easy-to-use logger for godot-rust projects.

godot-logger is an easy-to-use logger for godot-rust projects. It prints logs to Godot's output console and supports module-specific log levels.

A versatile and efficient proxy framework with nice features suitable for various use cases.

A versatile and efficient proxy framework with nice features suitable for various use cases.

A pretty, easy-to-use logger for Rust.
A pretty, easy-to-use logger for Rust.

pretty-env-logger A simple logger built on top of env_logger. It is configured via an environment variable and writes to standard error with nice colo

Another Key Logger Yet. Rust.

Another Key Logger Yet. Rust. For my very first experience of working with Rust, I decided to manage the keyboard, this time by logging and writing th

A pretty, sensible logger for Rust - ideal for running examples and tests on a crate of choice
A pretty, sensible logger for Rust - ideal for running examples and tests on a crate of choice

sensible-env-logger A pretty, sensible logger for Rust - ideal for running examples and tests on a crate of choice. This is a thin wrapper around pret

A loki logger for the log facade

Loki Logger A loki logger for the log facade. Examples extern crate log; extern crate loki_logger; use log::LevelFilter; #[tokio::main] async fn main

HTTP request logger

nosy - HTTP request logger How hard can it be to build your own HTTP request logger in Rust? Well, not that easy if you've never written a webapp in R

A standalone, `#![no_std]`-friendly `Logger` crate.

A standalone, #![no_std]-friendly Logger crate. Based on the design of the logger built into the bootloader crate and meant to be used in OS kernels.

Rall is an incredibly simple and intuitive logger
Rall is an incredibly simple and intuitive logger

Really...? Another Logging Library? Yes! :P rall is an incredibly simple and intuitive logger, consider this crate a failure if you can't get setup wi

API and logger for GBFS endpoints, noticeably Velib' in Paris

GBFS Watcher A daemon which logs Velib' stations statuses and provides a REST endpoint to access data. Velib' API is built over GBFS v1, so this API c

🔥 📝  (fwdt)
🔥 📝 (fwdt) "few word do trick" is a cross platform manual fast logger

Few Word Do Trick (fwdt) Few Word Do Trick (fwdt) is a cross-platform general purpose fast logger for humans that supports incomplete csvs for a bette

A dead simple logger that works globally and across threads.

Woody A logger for Rust that's *actually* easy to use. Features Easy to use: Just import the macros and you're good to go. No need to configure anythi

⚙️ Pre-commit hook for downgrading Python logger syntax

printf-log-formatter Automatically convert f-strings and str.format() syntax to printf-style strings. In other words, this syntax logger.error(f"{1}")

Owner
Rui Li
A beginner in programming, looking for internship opportunities. Email: lr_cn[at]outlook.com
Rui Li
A pretty, easy-to-use logger for Rust.

pretty-env-logger A simple logger built on top of env_logger. It is configured via an environment variable and writes to standard error with nice colo

Sean McArthur 390 Dec 29, 2022
Another Key Logger Yet. Rust.

Another Key Logger Yet. Rust. For my very first experience of working with Rust, I decided to manage the keyboard, this time by logging and writing th

(Not) Kearash 0 May 3, 2022
A pretty, sensible logger for Rust - ideal for running examples and tests on a crate of choice

sensible-env-logger A pretty, sensible logger for Rust - ideal for running examples and tests on a crate of choice. This is a thin wrapper around pret

Ritvik Nag 3 Aug 9, 2022
A loki logger for the log facade

Loki Logger A loki logger for the log facade. Examples extern crate log; extern crate loki_logger; use log::LevelFilter; #[tokio::main] async fn main

Thomas Nicollet 11 Dec 24, 2022
HTTP request logger

nosy - HTTP request logger How hard can it be to build your own HTTP request logger in Rust? Well, not that easy if you've never written a webapp in R

Manuel Hutter 1 Nov 26, 2021
A standalone, `#![no_std]`-friendly `Logger` crate.

A standalone, #![no_std]-friendly Logger crate. Based on the design of the logger built into the bootloader crate and meant to be used in OS kernels.

Kenny Strawn 1 Feb 6, 2022
Rall is an incredibly simple and intuitive logger

Really...? Another Logging Library? Yes! :P rall is an incredibly simple and intuitive logger, consider this crate a failure if you can't get setup wi

Hamothy 4 Sep 5, 2022
A dead simple logger that works globally and across threads.

Woody A logger for Rust that's *actually* easy to use. Features Easy to use: Just import the macros and you're good to go. No need to configure anythi

Travis A. Wagner 11 Apr 13, 2023
Logging implementation for Rust

log A Rust library providing a lightweight logging facade. log documentation A logging facade provides a single logging API that abstracts over the ac

The Rust Programming Language 1.6k Dec 29, 2022
Structured, contextual, extensible, composable logging for Rust

Getting started Introduction FAQ Crate list slog-rs - The Logging for Rust Introduction (please read) slog is an ecosystem of reusable components for

slog-rs 1.4k Jan 3, 2023