Add documentation for the logging module
This commit is contained in:
@@ -1,3 +1,42 @@
|
||||
//! Log handling and formatting of the console's output.
|
||||
//!
|
||||
//! # Logging
|
||||
//!
|
||||
//! Payphone uses the [`log`] crate for logging, and the [`colored`] crate for formatting the
|
||||
//! output.
|
||||
//!
|
||||
//! Any logs that are not coming from the `payphone` crate are ignored.
|
||||
//!
|
||||
//! ## Logging Levels
|
||||
//!
|
||||
//! There are 5 different logging levels:
|
||||
//!
|
||||
//! - `trace`: The most verbose level, used for debugging purposes.
|
||||
//! - `debug`: Events that are useful to be displayed during development, but not in production.
|
||||
//! - `info`: Used for general information about the bot's state and milestones.
|
||||
//! - `warn`: Used for warnings, when something unexpected happens but the bot can still continue
|
||||
//! running.
|
||||
//! - `error`: Used for errors, when something goes wrong and the bot cannot continue running.
|
||||
//!
|
||||
//! ## Usage
|
||||
//!
|
||||
//! Logging is quite simple as it works like any [`println!`] calls.
|
||||
//!
|
||||
//! ```
|
||||
//! log::trace!("This is a trace message.");
|
||||
//! log::debug!("This is a debug message.");
|
||||
//! log::info!("This is an info message.");
|
||||
//! log::warn!("This is a warning message.");
|
||||
//! log::error!("This is an error message.");
|
||||
//! ```
|
||||
//!
|
||||
//! Logging supports formatting, so you can use it like any other [`println!`] call:
|
||||
//!
|
||||
//! ```
|
||||
//! let value = 42;
|
||||
//! log::info!("The value is: {value}");
|
||||
//! ```
|
||||
|
||||
use colored::Colorize;
|
||||
use log::{Level, LevelFilter};
|
||||
use time::{OffsetDateTime, macros::format_description};
|
||||
|
||||
Reference in New Issue
Block a user