Skip to content

Commit

Permalink
feat: add log
Browse files Browse the repository at this point in the history
  • Loading branch information
indes committed Jun 20, 2021
1 parent b4be6c1 commit 6efddbf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions internal/bot/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"

"github.com/indes/telepush/internal/config"
_ "github.com/indes/telepush/internal/log"
"go.uber.org/zap"
tb "gopkg.in/tucnak/telebot.v2"
)
Expand Down
26 changes: 26 additions & 0 deletions internal/log/log.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package log

import (
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

var (
// Logger 日志对象
Logger *zap.Logger
zapConfig zap.Config
)

func init() {
zapConfig.Level = zap.NewAtomicLevelAt(zapcore.DebugLevel)
zapConfig.EncoderConfig = zap.NewDevelopmentEncoderConfig()

zapConfig.EncoderConfig.EncodeTime = zapcore.RFC3339TimeEncoder
zapConfig.OutputPaths = []string{"stderr"}
zapConfig.ErrorOutputPaths = []string{"stderr"}
zapConfig.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
zapConfig.Encoding = "console"

Logger, _ = zapConfig.Build()
zap.ReplaceGlobals(Logger)
}

0 comments on commit 6efddbf

Please sign in to comment.