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
//! Log levels and Encode trait
pub use Any;
pub use Write;
pub use Path;
pub use Mutex;
/// Log Level
///
/// This type is simply an alias for i32. It was not implemented as an enum to allow for extension.
///
/// ```
/// pub const LEVEL_CUSTOM : logkit::Level = 10; // use any number distinct from the built-ins
///
/// #[macro_export]
/// macro_rules! custom {
/// ($($arg:tt)*) => {{
/// logkit::record!(logkit::default_logger(), LEVEL_CUSTOM, $($arg)*)
/// }};
/// }
///
/// assert_eq!(logkit::default_logger().spawn(LEVEL_CUSTOM, logkit::source!()).unwrap().level(), LEVEL_CUSTOM);
/// custom!("this is a custom log level");
/// ```
pub type Level = i32;
/// Level Trace
pub const LEVEL_TRACE : Level = 0;
/// Level Debug
pub const LEVEL_DEBUG : Level = 1;
/// Level Info
pub const LEVEL_INFO : Level = 2;
/// Level Warn
pub const LEVEL_WARN : Level = 3;
/// Level Error
pub const LEVEL_ERROR : Level = 4;
/// Level Off
pub const LEVEL_OFF : Level = i32MAX;
/// Level to string
/// String to level
/// Encode Trait
///
/// This trait is used for formatting a field's value. Encoding support has already been added for
/// all scalar types and many standard collections. If you wish to format your own type, just
/// implement this trait.
///
/// ```
/// pub struct CustomStruct {
/// pub key1: i32,
/// pub key2: bool,
/// pub key3: String,
/// }
///
/// impl logkit::Encode for CustomStruct {
/// #[inline]
/// fn encode(&self, buf: &mut Vec<u8>) {
/// // format your struct into buf
/// unimplemented!()
/// }
/// }
/// ```
pub use Encode;