1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
//! # Prologger
//!
//! A production-grade, ergonomic Rust logging library with colored output,
//! file rotation, and structured formatting.
//!
//! Prologger implements the [`log`] crate facade, so you can use the standard
//! `log::info!()`, `log::warn!()`, etc. macros throughout your codebase.
//!
//! ## Quick Start
//!
//! ```rust,no_run
//! use log::{info, warn, error, debug};
//!
//! fn main() {
//! // Initialize with sensible defaults (colored console output at Info level)
//! prologger::init();
//!
//! info!("Application started");
//! debug!("This won't show at Info level");
//! warn!("Low disk space");
//! error!("Connection failed");
//! }
//! ```
//!
//! ## Builder API
//!
//! For fine-grained control, use the builder:
//!
//! ```rust,no_run
//! use log::LevelFilter;
//! use prologger::ProLoggerBuilder;
//!
//! ProLoggerBuilder::new()
//! .with_level(LevelFilter::Debug)
//! .with_console_default()
//! .with_module_filter("hyper", LevelFilter::Warn)
//! .init()
//! .unwrap();
//! ```
//!
//! ## Features
//!
//! | Feature | Default | Description |
//! |---------|---------|-------------|
//! | `color` | ✅ | ANSI colored terminal output |
//! | `file` | ✅ | File logging with size-based rotation |
//! | `json` | ❌ | JSON structured output formatter |
//! | `full` | ❌ | Enables all features |
// ─── Modules ──────────────────────────────────────────────────────────────
// ─── Re-exports ───────────────────────────────────────────────────────────
pub use ProLoggerBuilder;
pub use ColorMode;
pub use ;
pub use FormatterType;
pub use ProLogger;
pub use RotationConfig;
pub use ProloggerLayer;
// Re-export log crate essentials for convenience
pub use ;
// ─── Convenience Functions ────────────────────────────────────────────────
/// Initializes prologger with sensible defaults.
///
/// This sets up:
/// - Console output with auto-detected color support
/// - `Info` level filtering
/// - Pretty formatter
///
/// For more control, use [`ProLoggerBuilder`] instead.
///
/// # Panics
///
/// Panics if a global logger has already been set.
///
/// # Example
///
/// ```rust,no_run
/// prologger::init();
/// log::info!("Ready to go!");
/// ```
/// Initializes prologger with the given maximum log level.
///
/// # Panics
///
/// Panics if a global logger has already been set.
///
/// # Example
///
/// ```rust,no_run
/// use log::LevelFilter;
///
/// prologger::init_with_level(LevelFilter::Debug);
/// log::debug!("Verbose logging enabled");
/// ```
/// Tries to initialize prologger with sensible defaults.
///
/// Returns `Ok(())` on success, or `Err` if a logger was already set.
/// Use this instead of [`init`] when you want to handle the error gracefully.
/// Tries to initialize prologger with the given maximum log level.
/// Initializes prologger using the `RUST_LOG` environment variable.
///
/// This reads the `RUST_LOG` env var for level configuration:
/// - `RUST_LOG=debug` — sets global level to debug
/// - `RUST_LOG=warn,my_app=debug` — warn globally, debug for my_app
///
/// If `RUST_LOG` is not set, defaults to `Info` level.
///
/// # Panics
///
/// Panics if `RUST_LOG` contains invalid syntax or if a logger is already set.
///
/// # Example
///
/// ```rust,no_run
/// // Set RUST_LOG=debug before running
/// prologger::init_from_env();
/// log::debug!("This shows when RUST_LOG=debug");
/// ```
/// Tries to initialize prologger using the `RUST_LOG` environment variable.
///
/// Non-panicking version of [`init_from_env`].