packxel_utils/
lib.rs

1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3//! A bunch of utilities for the packxel project.
4//!
5//! ## Initializer
6//! ```
7//! use packxel_utils::initializer::Initializer;
8//!
9//! let version = env!("CARGO_PKG_VERSION");
10//! // creates the config and log directories.
11//! let initializer = Initializer::init("package-name", version);
12//! // the above would create $HOME/.config/package-name
13//! // and logs at $HOME/.config/package-name/logs
14//! ```
15//!
16//! ## Logging
17//! ```
18//! PackxelLogger::init(initializer).unwrap();
19//! // The use log crate from rust-lang
20//! // Writes to $HOME/.config/package-name/logs/packxel.log
21//! // where `package-name` is initializer.name.
22//! log::debug!("Hello World!");
23//! // Run with RUST_LOG=debug cargo run
24//! ```
25//!
26
27/// This is the main library for the packxel-utils crate.
28/// It contains the Initializer struct which is used to initialize
29/// This should be called before any program is initialized.
30pub mod initializer;
31
32/// An optional logging module for the packxel-utils crate.
33/// This should be called after the initializer is initialized.
34
35#[cfg(feature = "logging")]
36#[cfg_attr(docsrs, doc(cfg(feature = "logging")))]
37pub mod logging;