#logging #tui #log #filelog #cli

r3bl_simple_logger

Replacement for the simplelog crate, which is simpler and has clearer dependencies

4 releases

0.1.3 Oct 22, 2023
0.1.2 Oct 22, 2023
0.1.1 Oct 17, 2023
0.1.0 Oct 14, 2023

#303 in Command-line interface

Download history 5535/week @ 2023-12-18 6108/week @ 2023-12-25 6341/week @ 2024-01-01 6027/week @ 2024-01-08 5975/week @ 2024-01-15 6572/week @ 2024-01-22 5876/week @ 2024-01-29 5572/week @ 2024-02-05 5913/week @ 2024-02-12 5281/week @ 2024-02-19 4957/week @ 2024-02-26 4480/week @ 2024-03-04 4018/week @ 2024-03-11 3249/week @ 2024-03-18 2964/week @ 2024-03-25 3129/week @ 2024-04-01

13,873 downloads per month
Used in 8 crates (via r3bl_rs_utils_core)

Apache-2.0

5MB
2K SLoC

This is a fork & rewrite of the https://github.com/drakulix/simplelog.rs repo, for use by the https://crates.io/crates/r3bl_rs_utils_core crate.


lib.rs:

How to log things, and simply use the logging facilities

The simplest way to use this crate is to look at the r3bl_rs_utils_core::try_to_set_log_level function in the r3bl_rs_utils_core crate as the main entry point. By default, logging is disabled even if you call all the functions in the file_logger module in that crate: log_debug, log_info, log_trace, etc.

How to change how logging is implemented under the hood

Under the hood the simplelog crate is forked and modified for use here. The following are details for people who want to work on changing the underlying behavior of the logging engine itself, and not for folks who just want to use this crate.

r3bl_simple_logger provides a series of logging facilities, that can be easily combined.

  • SimpleLogger (very basic logger that logs to stdout)
  • TermLogger (advanced terminal logger, that splits to stdout/err and has color support) (can be excluded on unsupported platforms)
  • WriteLogger (logs to a given struct implementing Write, e.g. a file)
  • CombinedLogger (can be used to form combinations of the above loggers)
  • TestLogger (specialized logger for tests. Uses print!() / println!() for tests to be able to capture the output)

Only one Logger should be initialized of the start of your program through the Logger::init(...) method. For the actual calling syntax take a look at the documentation of the specific implementation(s) you wanna use.

Dependencies

~0.8–9.5MB
~65K SLoC