File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
23
23
### Security
24
24
- Nothing
25
25
26
+ ## [ 1.3.0] - 2019-03-18
27
+ ### Added
28
+ - ` Level ` now implements the ` envconfig.Decoder ` interface so it can be used in config types
29
+
30
+
26
31
## [ 1.2.0] - 2019-02-27
27
32
### Added
28
33
- ` ConfigureDefaultLogger ` boilerplate for logger configuration
Original file line number Diff line number Diff line change 1
1
// Package log is an alternative to log package in standard library.
2
2
package log
3
3
4
- import "os"
4
+ import (
5
+ "fmt"
6
+ "os"
7
+ )
5
8
6
9
type Level int
7
10
11
+ // Decode fills this level from the given input string.
12
+ // This makes `Level` implement the `Decoder` interface of `envconfig` library,
13
+ // so it can be used in config types seamlessly.
14
+ func (l * Level ) Decode (val string ) error {
15
+ if logLevel , ok := logLevelMap [val ]; ok {
16
+ * l = logLevel
17
+ return nil
18
+ } else {
19
+ return fmt .Errorf ("Unknown log level configured: %s" , val )
20
+ }
21
+ }
22
+
8
23
// Logging levels.
9
24
const (
10
25
CRITICAL Level = iota
You can’t perform that action at this time.
0 commit comments