Skip to content

Commit

Permalink
update to 0.1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
kataras committed Dec 9, 2020
1 parent 133471d commit f7561df
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Wed 09 Decemember | v0.1.6

Fix `Clone` not inherite the parent's formatters field (fixes `SetLevelFormat` on childs).

## Mo 07 September | v0.1.5

Introduce the [Formatter](https://github.com/kataras/golog/blob/master/formatter.go) interface. [Example](https://github.com/kataras/golog/tree/master/_examples/customize-output).
Expand Down
1 change: 1 addition & 0 deletions _examples/rotation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func main() {
if err != nil {
golog.Fatal(err)
}
defer w.Close()

golog.SetOutput(w)

Expand Down
5 changes: 4 additions & 1 deletion formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ type Formatter interface {
type JSONFormatter struct {
Indent string

// use one encoder per level, do not create new each time.
// Use one encoder per level, do not create new each time.
// Even if the jser can set a different formatter for each level
// on SetLevelFormat, the encoding's writers may be different
// if that ^ is not called but SetLevelOutput did provide a different writer.
encoders map[Level]*json.Encoder
mu sync.RWMutex // encoders locker.
encMu sync.Mutex // encode action locker.
Expand Down
4 changes: 3 additions & 1 deletion log.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ func GetStacktrace(limit int) (callerFrames []Frame) {
}

if strings.Contains(file, "github.com/kataras/golog") &&
!(strings.Contains(file, "_examples") || strings.Contains(file, "_test.go")) {
!(strings.Contains(file, "_examples") ||
strings.Contains(file, "_test.go") ||
strings.Contains(file, "integration.go")) {
continue
}

Expand Down
10 changes: 5 additions & 5 deletions logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,11 +266,11 @@ func (l *Logger) SetLevelFormat(levelName string, formatter string, opts ...inte
func (l *Logger) getFormatter() Formatter {
f, ok := l.LevelFormatter[l.Level]
if !ok {
if l.formatter != nil {
f = l.formatter
} else {
f = nil
}
f = l.formatter
}

if f == nil {
return nil
}

return f
Expand Down

0 comments on commit f7561df

Please sign in to comment.