| Crates.io | plogger |
| lib.rs | plogger |
| version | 0.0.1 |
| created_at | 2022-08-03 05:45:43.298954+00 |
| updated_at | 2022-08-03 05:45:43.298954+00 |
| description | A simple, ready to import logger for your projects |
| homepage | https://pietrobongiovanni.com |
| repository | https://github.com/pgoodjohn/plogger |
| max_upload_size | |
| id | 637802 |
| size | 3,991 |
Plogger (Pietro's Logger) is a simple to initialise logger to get started with your next Rust project.
plogger is a wrapper around env_logger, with a less configurable - more straight forward - one line initialisation and some sensible defaults.
Initialise simple logger as early as you can in your main() body by calling:
use plogger;
fn main() {
let debug = true; // or false
plogger::init(debug);
}
You can now use the log's crate macros to log from your program:
fn some_method() {
log::info!("An info log!");
log::debug!("A debug log!");
log::warn!("A warn log!");
}
Plogger has two modes of operation: normal and debug mode. You can specify which mode you want when initialising the logger via the boolean parameter debug.
Plogger always logs to stdout, the differences between normal and debug mod include the format of log messages and the level of logs that will be displayed.
In normal mode, enabled with debug=false, Plogger will only log messages up to Info level with the following format:
{log timestamp} - {log message}
In debug mode, enabled with debug=true, Plogger will log all messages up to Debug level with the following format:
{log timestamp} [{log level}] - {log file}:{log line }- {log message}