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

🧠 - Logs a message at the custom level.
🔮 - Logs a message at the debug level.
💥 - Logs a message at the error level.
😵 - Logs a message at the Fatal level.
💭 - Logs a message at the help level.
📰 - Logs a message at the info level.
🎉 - Logs a message at the success level.
🔧 - Logs a message at the trace level.
💡 - Logs a message at the warn level.

Enums

Flag either a Level or a String.
Level enum.

Functions

The standard logging function.