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
#![deny(
    missing_docs,
    trivial_casts,
    trivial_numeric_casts,
    unsafe_code,
    unstable_features,
    unused_import_braces,
    unused_qualifications
)]

//!## Usage
//!
//!All examples can be found in the `examples` directory.
//!
//!### Basic
//!
//!The simpliest way is just to call `init`.
//!The default log level is `Info`, so that debug and trace messages are not shown.
//!
//!``` rust
//!//! examples/01_basic.rs
//!//! # Basic usage for the logger
//!use log::{error, warn, info, debug, trace};
//!use loggify::Loggify;
//!
//!/// The default level is INFO. So debug and trace outputs are oppressed
//!fn main() {
//!    Loggify::init().unwrap();
//!
//!    error!("My error message");
//!    warn!("My warn message");
//!    info!("My info message");
//!    debug!("Will not be shown");
//!    trace!("Will not be shown");
//!}
//!```
//!
//!### With log level
//!
//!``` rust
//!//! examples/02_log_level.rs
//!//! Example for initializing the logger with a log level
//!use log::{error, warn, info, debug, trace, Level};
//!use loggify::Loggify;
//!
//!/// Same as the basic example with the difference that
//!/// the logger is intialized with the debug log level.
//!fn main() {
//!    Loggify::init_with_level(Level::Debug).unwrap();
//!
//!    error!("My error message");
//!    warn!("My warn message");
//!    info!("My info message");
//!    debug!("My debug message");
//!    trace!("Will not be shown");
//!}
//!```
//!
//!### Log builder
//!``` rust
//!//! examples/03_builder.rs
//!//! Example for initializing the logger with the LogBuilder
//!use log::{error, warn, info, debug, trace};
//!use loggify::LogBuilder;
//!
//!/// The `LogBuilder` is used to set more logger options
//!/// This example will change the log level to Trace
//!/// and the printed time format to time only
//!fn main() {
//!    LogBuilder::new()
//!        .set_level(log::Level::Trace)
//!        .set_time_format(String::from("%H:%M:%S"))
//!        .build()
//!        .unwrap();
//!
//!    error!("My error message");
//!    warn!("My warn message");
//!    info!("My info message");
//!    debug!("My debug message");
//!    trace!("My trace message");
//!}
//!```
//!
//!### Exclude targets from log
//!
//!``` rust
//!//! examples/04_exclude.rs
//!//! Example for excluding log targets from getting logged
//!use log::{error, warn, info, debug, trace};
//!use loggify::LogBuilder;
//!
//!mod example {
//!    pub mod excluded {
//!        use log::info;
//!
//!        pub fn call_me() {
//!            info!("I will not be logged");
//!        }
//!    }
//!
//!    pub mod included {
//!        use log::info;
//!
//!        pub fn call_me() {
//!            info!("I will be logged");
//!        }
//!    }
//!}
//!
//!/// Exmple on how to exclude specific log targets
//!fn main() {
//!    LogBuilder::new()
//!        // this will show the log targets so that we can determine
//!        // what to exclude
//!        .set_log_target(true)
//!        // this will oppress all logs coming from example::excluded::*
//!        .add_exclude("example::excluded".to_string())
//!        .set_level(log::Level::Trace)
//!        .build()
//!        .unwrap();
//!
//!    error!("My error message");
//!    warn!("My warn message");
//!    info!("My info message");
//!    debug!("My debug message");
//!    trace!("My trace message");
//!
//!    // the log message of this call will not be shown
//!    example::excluded::call_me();
//!    // this log message will be shown
//!    example::included::call_me();
//!}
//!```

mod loggify;
mod log_builder;

pub use self::loggify::Loggify;
pub use self::log_builder::LogBuilder;