Crate logi

Crate logi 

Source
Expand description

ยงLogi library

This library is used to log messages in a structured and beautiful way.

ยงAbout

This lib uses the println macro to log messages, exposes some macros to log messages in different levels.

The levels are:

  • trace: for debug messages.
  • debug: for info messages.
  • success: for success messages.
  • warn: for warning messages.
  • error: for error messages.
  • custom: for custom messages.

ยงExamples

#[macro_use] // We only need to import some macros to use `Logi`.
extern crate logi;

// Let's start logging!
fn main() {
   // Info level.
   trace!("Starting the CLI.");   // 02:12:22 | ๐Ÿ”ง TRCE | Starting the CLI.
   debug!("Starting the CLI.");   // 02:12:22 | ๐Ÿ”ฎ DBUG | Starting the CLI.

   // Confirmation level.
   success!("Starting the CLI."); // 02:12:22 | ๐ŸŽ‰ YEEE | Starting the CLI.

   // Warning & Error levels.
   warn!("Starting the CLI.");    // 02:12:22 | ๐Ÿ’ก WARN | Starting the CLI.
   error!("Starting the CLI.");   // 02:12:22 | ๐Ÿ’ฅ F#CK | Starting the CLI.

   // Custom level. (Thats a different macro, here we define the level of the message as the way we want.)
   custom!("๐Ÿงญ CSTM".to_string(), format!("Starting the {}.", "CLI")); // 20:39:24 | ๐Ÿงญ CSTM | Starting the CLI.
}

Macrosยง

custom
๐Ÿง  - Logs a message at the custom level.
debug
๐Ÿ”ฎ - Logs a message at the debug level.
error
๐Ÿ’ฅ - Logs a message at the error level.
fatal
๐Ÿ˜ต - Logs a message at the Fatal level.
help
๐Ÿ’ญ - Logs a message at the help level.
info
๐Ÿ“ฐ - Logs a message at the info level.
success
๐ŸŽ‰ - Logs a message at the success level.
trace
๐Ÿ”ง - Logs a message at the trace level.
warn
๐Ÿ’ก - Logs a message at the warn level.

Enumsยง

Flag
Flag either a Level or a String.
Level
Level enum.

Functionsยง

log
The standard logging function.