Documentation
¶
Index ¶
- Variables
- func Reload(lv zapcore.Level, modules ModulesLevel)
- func Sync() error
- type Config
- type CoreConstructor
- type Cores
- func (t Cores) Build(ctx context.Context, registry prometheus.Registerer) (core []zapcore.Core, err error)
- func (t Cores) BuildByName(ctx context.Context, registry prometheus.Registerer, name string) (core zapcore.Core, err error)
- func (t Cores) MustBuild(ctx context.Context, registry prometheus.Registerer) []zapcore.Core
- type Logger
- type Logzap
- type ModulesLevel
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidModuleLevel = fmt.Errorf("invalid module level") ErrUnsupportedFields = fmt.Errorf("unsupported fields") )
View Source
var ( ErrUnsupportedCoreConstructor = errors.New("unsupported core constructor") ErrCoreNotFound = errors.New("core not found") )
View Source
var MapStructureLevelDecodeHook = []mapstructure.DecodeHookFunc{
levelDecodeHookFunc,
mapStringDecodeHookFunc,
}
Functions ¶
func Reload ¶
func Reload(lv zapcore.Level, modules ModulesLevel)
Reload reload global instance with given log level.
Types ¶
type Config ¶
type Config struct { Level zapcore.Level `yaml:"level"` Modules ModulesLevel `yaml:"modules,omitempty"` Cores Cores `yaml:"cores,omitempty"` }
type CoreConstructor ¶
type CoreConstructor func(ctx context.Context, registry prometheus.Registerer, url string) (zapcore.Core, error)
type Cores ¶
func (Cores) Build ¶
func (t Cores) Build( ctx context.Context, registry prometheus.Registerer, ) (core []zapcore.Core, err error)
func (Cores) BuildByName ¶
func (t Cores) BuildByName( ctx context.Context, registry prometheus.Registerer, name string, ) (core zapcore.Core, err error)
func (Cores) MustBuild ¶
func (t Cores) MustBuild( ctx context.Context, registry prometheus.Registerer, ) []zapcore.Core
type Logger ¶
type Logger interface { // Error logs a message at ErrorLevel if err is not nil. Trace(err error, fields ...zap.Field) // TraceError logs a message at ErrorLevel if err is not nil. TraceError(err error, fields ...zap.Field) error // TraceContext logs a message at ErrorLevel if err is not nil and ctx is not done. TraceContext(ctx context.Context, err error, fields ...zap.Field) error // Error logs a message at ErrorLevel. The message includes any fields passed Error(msg string, fields ...zap.Field) // Warn logs a message at WarnLevel. The message includes any fields passed Warn(msg string, fields ...zap.Field) // Info logs a message at InfoLevel. The message includes any fields passed Info(msg string, fields ...zap.Field) // Debug logs a message at DebugLevel. The message includes any fields passed Debug(msg string, fields ...zap.Field) // Errorf uses fmt.Sprintf to log a templated message at ErrorLevel. Errorf(format string, args ...interface{}) // Warnf uses fmt.Sprintf to log a templated message at WarnLevel. Warnf(format string, args ...interface{}) // Infof uses fmt.Sprintf to log a templated message at InfoLevel. Infof(format string, args ...interface{}) // Debugf uses fmt.Sprintf to log a templated message at DebugLevel. Debugf(format string, args ...interface{}) // Increase increase log level Increase(lv zapcore.Level) Logger // Level return zapcore.LevelEnabler // L return zap.Logger L() *zap.Logger }
type Logzap ¶
type Logzap struct {
// contains filtered or unexported fields
}
func New ¶
func New( ctx context.Context, registry prometheus.Registerer, c Config, ) *Logzap
New return a instance with given configuration. Note that it will panic if any error occurred.
func NewE ¶
func NewE( ctx context.Context, registry prometheus.Registerer, c Config, ) (t *Logzap, err error)
NewE return a instance and error with given configuration.
Click to show internal directories.
Click to hide internal directories.