mirror of
https://github.com/project-zot/zot.git
synced 2024-12-30 22:34:13 -05:00
Fix logger race condition (#817)
Signed-off-by: Laurentiu Niculae <niculae.laurentiu1@gmail.com>
This commit is contained in:
parent
6b1d8925c2
commit
b9d878e013
1 changed files with 10 additions and 2 deletions
|
@ -5,6 +5,7 @@ import (
|
|||
"runtime"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
|
@ -12,6 +13,9 @@ import (
|
|||
|
||||
const defaultPerms = 0o0600
|
||||
|
||||
// nolint:gochecknoglobals
|
||||
var loggerSetTimeFormat sync.Once
|
||||
|
||||
// Logger extends zerolog's Logger.
|
||||
type Logger struct {
|
||||
zerolog.Logger
|
||||
|
@ -22,7 +26,9 @@ func (l Logger) Println(v ...interface{}) {
|
|||
}
|
||||
|
||||
func NewLogger(level, output string) Logger {
|
||||
zerolog.TimeFieldFormat = time.RFC3339Nano
|
||||
loggerSetTimeFormat.Do(func() {
|
||||
zerolog.TimeFieldFormat = time.RFC3339Nano
|
||||
})
|
||||
|
||||
lvl, err := zerolog.ParseLevel(level)
|
||||
if err != nil {
|
||||
|
@ -47,7 +53,9 @@ func NewLogger(level, output string) Logger {
|
|||
}
|
||||
|
||||
func NewAuditLogger(level, audit string) *Logger {
|
||||
zerolog.TimeFieldFormat = time.RFC3339Nano
|
||||
loggerSetTimeFormat.Do(func() {
|
||||
zerolog.TimeFieldFormat = time.RFC3339Nano
|
||||
})
|
||||
|
||||
lvl, err := zerolog.ParseLevel(level)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue