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
//! # duryLog
//!
//! This crate adds logging to your projects or library.
//!
//! After trying a lot of crates to make logging, I only found crates rich of futures but very complicate to use,
//! or crates that are easy to use but log only on file or only on console.
//!
//! I decided to write my own lib that aims to be **easy to use with some usefull futures**:
//! * Can log only on stdout, only on file or both.
//! * Very easy to start: install and use immediately.
//! * Short API names.
//! * It implements [log](https://crates.io/crates/log) crate so you can use Rust library logging macros.
//!
//! ## Add to project:
//! In file cargo.toml add:
//! ```toml
//! [dependencies]
//! durylog = "0.1.0"
//! ```
//! ## Getting Start
//! There are 2 way for use this crate:
//! * Directly create object: ```let durylog=DLog::new();``` and use like ```durylog.d("Log message");```
//! * Initialize logger: ```DLog::new().init_logger().ok();``` and use with [log](https://crates.io/crates/log) macro like ```debug!("Log message");```
//!
//! Read [documentation](https://docs.rs/durylog/) and [examples](examples/).
//!
//! Output (on console and/or file) for default settings is like:
//! ```toml
//! 2023/01/02 18.01.27 : DEBUG : Debug message
//! ```
//! First tag is datetime stamp, second tag is level name followed by log message tag
//! ## Examples:
//! ### Directly usage with default settings:
//! ```rust
//! use durylog::DLog;
//!
//! fn main() {
//! let durylog=DLog::new();
//!
//! println!("{}", durylog.get_status()); // This prints all current crate settings (in this case are defaults)
//!
//! durylog.e("Error message");
//! durylog.w("Warning message");
//! durylog.i("Info message");
//! durylog.d("Debug message");
//! durylog.t("Trace message");
//! }
//! ```
//! This will log on stdout without colors.
//!
//! ### Directly usage with custom settings:
//! ```rust
//! use durylog::DLog;
//!
//! fn main() {
//! let durylog=DLog::new()
//! .with_color() // Enable colors in console output (default disabled)
//! .widh_timestamp_format("%Y-%m-%d %H:%M:%S") // Change default timestamp
//! .widh_custom_separator(" | ") // Change default separator pattern for items
//! .with_file("durylog-custom.log").unwrap(); // Enable logging on file (default disable)
//!
//! println!("{}", durylog.get_status()); // This prints all current crate settings (in this case there are custom)
//!
//! durylog.e("Error message");
//! durylog.w("Warning message");
//! durylog.i("Info message");
//! durylog.d("Debug message");
//! durylog.t("Trace message");
//! }
//! ```
//! This will log on stdout with colors, different formatting for timestamp and different tags separator and in file durylog-custom.log are added same log lines as in console.
//!
//! ### Macros usage with default settings:
//! ```rust
//! use durylog::{error,warn,info,debug,trace,DLog};
//!
//! fn main() {
//! DLog::new().init_logger().ok();
//!
//! error!("Error message");
//! warn!("Warning message");
//! info!("Info message");
//! debug!("Debug message");
//! trace!("Trace message");
//! }
//! ```
//! This will log on stdout without colors.
//!
//! ### Macros usage with custom settings:
//! ```rust
//! use durylog::{error,warn,info,debug,trace,DLog};
//!
//! fn main() {
//! DLog::new()
//! .with_color() // Enable colors in console output (default disabled)
//! .widh_timestamp_format("%Y-%m-%d %H:%M:%S") // Change default timestamp
//! .widh_custom_separator(" | ") // Change default separator pattern for items
//! .with_file("log-custom.log").unwrap() // Enable logging on file (default disable)
//! .init_logger().ok();
//!
//! error!("Error message");
//! warn!("Warning message");
//! info!("Info message");
//! debug!("Debug message");
//! trace!("Trace message");
//! }
//! ```
//! This will log on stdout with colors, different formatting for timestamp and different tags separator and in file log-custom.log are added same log lines as in console.
//!
/// the only module in this crate.
pub use crateDLog;
pub use cratedebug;
pub use crateerror;
pub use cratewarn;
pub use crateinfo;
pub use cratetrace;