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
//! Quil is a easy to use library that supports message levels, multiple
//! output targets, sub-loggers, and message contexts. Quil can be used across
//! threads safely, and is easy to extend.
//!
//! # Examples
//!
//! Basic example:
//!
//! ```rust
//! # #[macro_use] extern crate quil;
//! # fn main() {
//! # use quil::prelude::*;
//! let logger = Logger::new(Console::new(), context!{ src: "root" });
//!
//! logger.info("hello world");
//! # }
//! ```
//!
//! ```shell
//! Tue, 7 Nov 2017 23:55:42 +0000 - info: hello world src=root
//! ```
//!
//! Sub-context example:
//!
//! ```rust
//! # #[macro_use] extern crate quil;
//! # fn main() {
//! # use quil::prelude::*;
//! let logger = Logger::new(Console::new(), context!{ src: "root", tag: "1" });
//! logger.info("hello");
//!
//! let sub_logger = logger.ctx(context!{ tag: "", marker: "49" });
//! logger.info("world");
//! # }
//! ```
//!
//! ```shell
//! Tue, 7 Nov 2017 23:55:42 +0000 - info: hello src=root tag=1
//! Tue, 7 Nov 2017 23:55:42 +0000 - info: world src=root marker=49
//! ```
//!
//! Multi-target example:
//!
//! ```rust
//! # #[macro_use] extern crate quil;
//! # fn main() {
//! # use quil::prelude::*;
//! let logger = Logger::new(targets![
//! Console::new(),
//! JsonFile::open("path/to/logfile.json"),
//! ], context!{ some_meta_key: "some_meta_value" });
//!
//! logger.info("hello");
//!
//! let sub_logger = logger.ctx(context!{ marker: "49" });
//! logger.warn("world");
//! # }
//! ```
//!
//! _Shell_:
//!
//! ```shell
//! Tue, 7 Nov 2017 23:55:42 +0000 - info: hello some_meta_key=some_meta_value
//! Tue, 7 Nov 2017 23:55:42 +0000 - warn: world some_meta_key=some_meta_value marker=49
//! ```
//! _Log File_:
//!
//! ```json
//! { "level": "info", "message": "hello", "context": { "some_meta_key": "some_meta_value" } }
//! { "level": "warn", "message": "world", "context": { "some_meta_key": "some_meta_value", "marker": "49" } }
//! ```
extern crate chrono;
extern crate colored;
pub use Target;
pub use Context;
pub use Level;
pub use Logger;
/// A convenience module that can be used to include commonly used quil types.
///
/// # Examples
///
/// ```rust
/// use quil::prelude::*;
/// ```