-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
36 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
--- | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
hooks: | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: git://github.com/dnephin/pre-commit-golang | ||
rev: v0.4.0 | ||
hooks: | ||
- id: go-fmt | ||
- id: go-imports | ||
- id: golangci-lint | ||
- id: go-unit-tests | ||
- id: go-build | ||
- id: go-mod-tidy | ||
- id: go-mod-vendor | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
hooks: | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: git://github.com/dnephin/pre-commit-golang | ||
rev: v0.4.0 | ||
hooks: | ||
- id: go-mod-vendor | ||
- id: go-fmt | ||
- id: go-imports | ||
- id: validate-toml | ||
- id: golangci-lint | ||
- id: go-unit-tests | ||
- id: go-build | ||
- id: go-mod-tidy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,30 @@ | ||
package logging | ||
|
||
import "go.uber.org/zap" | ||
|
||
var ( | ||
logger *zap.Logger | ||
err error | ||
import ( | ||
"go.uber.org/zap" | ||
"go.uber.org/zap/zapcore" | ||
"os" | ||
) | ||
|
||
var logger *zap.Logger | ||
|
||
func init() { | ||
logger, err = zap.NewProduction() | ||
if err != nil { | ||
panic(err) | ||
cfgConsole := zapcore.EncoderConfig{ | ||
MessageKey: "message", | ||
LevelKey: "severity", | ||
EncodeLevel: zapcore.LowercaseLevelEncoder, | ||
TimeKey: "time", | ||
EncodeTime: zapcore.RFC3339TimeEncoder, | ||
CallerKey: "caller", | ||
EncodeCaller: zapcore.FullCallerEncoder, | ||
} | ||
|
||
core := zapcore.NewTee(zapcore.NewCore(zapcore.NewJSONEncoder(cfgConsole), zapcore.Lock(os.Stdout), zap.InfoLevel)) | ||
logger = zap.New(core) | ||
logger.Info("An info level message") | ||
} | ||
|
||
// GetLogger returns the common *zap.Logger | ||
// GetLogger returns the shared *zap.Logger | ||
func GetLogger() *zap.Logger { | ||
return logger | ||
} |