octopush/internal/logger/zap.go
kjuulh 46cc160764
Examples, rename and fixes
updated roadmap

updated roadmap

Add a basic readme (#15)

Co-authored-by: kjuulh <contact@kjuulh.io>
Reviewed-on: kjuulh/kraken#15

fix readme

Add readme

with stuff

more roadmap items

update formatting

formatting 2

more setup

with semantic

with semantic 2

revert

add releaserc

with releaser

with kraken

Update roadmap

rename

rename

feature/move-command (#18)

Co-authored-by: kjuulh <contact@kjuulh.io>
Reviewed-on: #18

fix/require-two-pushes (#20)

Co-authored-by: kjuulh <contact@kjuulh.io>
Reviewed-on: #20
2022-09-21 22:52:24 +02:00

34 lines
834 B
Go

package logger
import (
"os"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
func New() (*zap.Logger, error) {
highPriority := zap.LevelEnablerFunc(func(lvl zapcore.Level) bool {
return lvl >= zapcore.ErrorLevel
})
lowPriority := zap.LevelEnablerFunc(func(lvl zapcore.Level) bool {
return lvl < zapcore.ErrorLevel // && lvl > zapcore.DebugLevel
})
config := zap.NewDevelopmentEncoderConfig()
config.EncodeTime = nil
config.EncodeLevel = zapcore.CapitalColorLevelEncoder
consoleEncoder := zapcore.NewConsoleEncoder(config)
consoleDebugging := zapcore.Lock(os.Stdout)
consoleErrors := zapcore.Lock(os.Stderr)
core := zapcore.NewTee(
zapcore.NewCore(consoleEncoder, consoleErrors, highPriority),
zapcore.NewCore(consoleEncoder, consoleDebugging, lowPriority),
)
logger := zap.New(core)
return logger, nil
}