File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -53,3 +53,4 @@ glob = "0.3"
53
53
lazy_static = " 1"
54
54
notify = " ^5.0.0"
55
55
temp-env = " 0.3.0"
56
+ log = { version = " 0.4" , features = [" serde" ] }
Original file line number Diff line number Diff line change
1
+ extern crate config;
2
+ extern crate log;
3
+
4
+ #[ macro_use]
5
+ extern crate serde_derive;
6
+
7
+ use config:: * ;
8
+
9
+ #[ derive( Debug , Deserialize ) ]
10
+ struct Settings {
11
+ log : log:: Level ,
12
+ }
13
+
14
+ fn config ( s : & str ) -> Config {
15
+ Config :: default ( )
16
+ . merge ( File :: from_str ( s, FileFormat :: Json ) )
17
+ . unwrap ( )
18
+ . clone ( )
19
+ }
20
+
21
+ #[ test]
22
+ fn test_load_level_uppercase ( ) {
23
+ let s = r#"{ "log": "ERROR" }"# ;
24
+ let c = config ( s) ;
25
+ let l = c. get :: < log:: Level > ( "log" ) . unwrap ( ) ;
26
+ assert_eq ! ( l, log:: Level :: Error ) ;
27
+ }
28
+
You can’t perform that action at this time.
0 commit comments