1
0
mirror of https://github.com/khorevaa/logos.git synced 2024-11-24 08:52:19 +02:00
logos/warp_zap.go
Aleksey Khorev 0b3e159306 fix: исправлена ошибка в консоле. Переход на AtomicLevel
Добавлены Named, With - клонеры логгера. Работа с контекстом
2022-02-18 23:45:52 +03:00

33 lines
691 B
Go

package logos
import (
"github.com/khorevaa/logos/appender"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
var StackTraceLevelEnabler = zap.NewAtomicLevelAt(zapcore.PanicLevel)
func newZapCore(config map[string]zap.AtomicLevel, appenders map[string]*appender.Appender) zapcore.Core {
zcs := make([]zapcore.Core, 0)
for name, level := range config {
if a, ok := appenders[name]; ok {
zcs = append(zcs, zapcore.NewCore(a.Encoder, a.Writer, level))
}
}
if len(zcs) == 0 {
return zapcore.NewNopCore()
}
return zapcore.NewTee(zcs...)
}
func newZapLogger(name string, core zapcore.Core, option ...zap.Option) *zap.Logger {
return zap.New(core, option...).Named(name)
}