Skip to content

Commit

Permalink
logger_test: added sampler and writer logger to compare better
Browse files Browse the repository at this point in the history
  • Loading branch information
Reza Kamalifard committed Jul 24, 2020
1 parent 0282b65 commit baaac8c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
19 changes: 1 addition & 18 deletions logger.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package logger

import (
"go.uber.org/zap"
Expand All @@ -18,23 +18,6 @@ func (m *Message) MarshalLogObject(enc zapcore.ObjectEncoder) error {
return nil
}

func main() {
// we create a new logger and set the environment for it (production)
logger, err := zap.NewProduction()
defer logger.Sync()

if err != nil {
panic(err)
}
// initialize sugar logger
sugar := logger.Sugar()

// create new message
msg := &Message{"message_text", 1}
sugarLogger(sugar, msg)
structuredLogger(logger, msg)
}

func sugarLogger(sugar *zap.SugaredLogger, msg *Message) {
sugar.Infow("logger",
"type", "logger",
Expand Down
2 changes: 1 addition & 1 deletion logger_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package logger

import (
"github.com/rezakamalifard/BenchmarkZapLoggers/internal/ztest"
Expand Down

0 comments on commit baaac8c

Please sign in to comment.