librarius 0.1.1

A simple and lightweight logging library for Rust. It provides a flexible framework for emitting log messages from Rust programs, with support for different log levels and output formats.
Documentation
  • Coverage
  • 0%
    0 out of 28 items documented0 out of 9 items with examples
  • Size
  • Source code size: 15.81 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.02 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 20s Average build duration of successful builds.
  • all releases: 18s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • joaoprado-rs/librarius
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • joaoprado-rs

Librarius

Librarius is a logging library in Rust that provides logging functionality for different severity levels, such as Info, Warn, Error, and Debug. The library allows logs to be sent to the terminal or a file, depending on the configuration. It is easy to integrate and configure within any Rust application.

Features

  • Support for multiple log levels: Info, Warn, Error, Debug.
  • Logs can be output to the terminal or written to a file.
  • Custom log formatting with date, time, and timezone.
  • Easy integration with logging macros (info!, warn!, error!).
  • Simple configuration using the Config struct.

Installation

Add the following dependency to your Cargo.toml:

[dependencies]
librarius = "0.1"

Usage Example

Logging at the terminal

use librarius::{Logger, Level, Config};

fn main() {

    // Create the configuration
    let config = Config::new(Level::Info);
    
    // Initialize the logger
    librarius::init(config);

    // Using the log macros
    info!("This is an info log");
    warn!("This is a warning log");
    error!("This is an error log");
    debug!("This is a debug log");
}

Logging at a file

use librarius::{Logger, Level, Config};

fn main() {

    // Create the configuration
    let config = Config::with_file(Level::Info, "logs.txt");
    
    // Initialize the logger
    librarius::init(config);

    // Using the log macros
    info!("This is an info log");
    warn!("This is a warning log");
    error!("This is an error log");
    debug!("This is a debug log");
}

Configuration

You can configure Librarius by creating a Config, where you define the log level and whether logs should be written to a file:

use librarius::{Config, Level};

let config = Config::with_file(Level::Info, "logs.txt");

License

This project is licensed under the MIT License - see the LICENSE file for details.