logger

package module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2020 License: MIT Imports: 10 Imported by: 12

Documentation

Index

Constants

View Source
const PluginName = "logs"

PluginName declares plugin name.

Variables

This section is empty.

Functions

func ColoredHashedNameEncoder

func ColoredHashedNameEncoder(s string, enc zapcore.PrimitiveArrayEncoder)

ColoredHashedNameEncoder colorizes service names and assigns different colors to different names.

func ColoredLevelEncoder

func ColoredLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder)

ColoredLevelEncoder colorizes log levels.

func ColoredNameEncoder

func ColoredNameEncoder(s string, enc zapcore.PrimitiveArrayEncoder)

ColoredNameEncoder colorizes service names.

func UTCTimeEncoder

func UTCTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)

UTCTimeEncoder encodes time into short UTC specific timestamp.

Types

type ChannelConfig

type ChannelConfig struct {
	// Dedicated channels per logger. By default logger allocated via named logger.
	Channels map[string]Config `json:"channels" yaml:"channels"`
}

ChannelConfig configures loggers per channel.

type Config

type Config struct {
	// Mode configures logger based on some default template (development, production, off).
	Mode string `json:"mode" yaml:"mode"`

	// Level is the minimum enabled logging level. Note that this is a dynamic
	// level, so calling ChannelConfig.Level.SetLevel will atomically change the log
	// level of all loggers descended from this config.
	Level string `json:"level" yaml:"level"`

	// Encoding sets the logger's encoding. Valid values are "json" and
	// "console", as well as any third-party encodings registered via
	// RegisterEncoder.
	Encoding string `json:"encoding" yaml:"encoding"`

	// Output is a list of URLs or file paths to write logging output to.
	// See Open for details.
	Output []string `json:"output" yaml:"output"`

	// ErrorOutput is a list of URLs to write internal logger errors to.
	// The default is standard error.
	//
	// Note that this setting only affects internal errors; for sample code that
	// sends error-level logs to a different location from info- and debug-level
	// logs, see the package-level AdvancedConfiguration example.
	ErrorOutput []string `json:"errorOutput" yaml:"errorOutput"`
}

func (*Config) BuildLogger

func (cfg *Config) BuildLogger() (*zap.Logger, error)

ZapConfig converts config into Zap configuration.

type Logger

type Logger interface {
	Debug(msg string, keyvals ...interface{})
	Info(msg string, keyvals ...interface{})
	Warn(msg string, keyvals ...interface{})
	Error(msg string, keyvals ...interface{})
}

Logger is an general RR log interface

type WithLogger

type WithLogger interface {
	With(keyvals ...interface{}) Logger
}

With creates a child logger and adds structured context to it

type ZapAdapter

type ZapAdapter struct {
	// contains filtered or unexported fields
}

func NewZapAdapter

func NewZapAdapter(zapLogger *zap.Logger) *ZapAdapter

Create NewZapAdapter which uses general log interface

func (*ZapAdapter) Debug

func (log *ZapAdapter) Debug(msg string, keyvals ...interface{})

func (*ZapAdapter) Error

func (log *ZapAdapter) Error(msg string, keyvals ...interface{})

func (*ZapAdapter) Info

func (log *ZapAdapter) Info(msg string, keyvals ...interface{})

func (*ZapAdapter) Warn

func (log *ZapAdapter) Warn(msg string, keyvals ...interface{})

func (*ZapAdapter) With

func (log *ZapAdapter) With(keyvals ...interface{}) Logger

type ZapLogger

type ZapLogger struct {
	// contains filtered or unexported fields
}

ZapLogger manages zap logger.

func (*ZapLogger) DefaultLogger

func (z *ZapLogger) DefaultLogger() (Logger, error)

DefaultLogger returns default logger.

func (*ZapLogger) Init

func (z *ZapLogger) Init(cfg config.Configurer) error

Init logger service.

func (*ZapLogger) NamedLogger

func (z *ZapLogger) NamedLogger(name string) (Logger, error)

NamedLogger returns logger dedicated to the specific channel. Similar to Named() but also reads the core params.

func (*ZapLogger) Provides

func (z *ZapLogger) Provides() []interface{}

Provides declares factory methods.

func (*ZapLogger) ServiceLogger

func (z *ZapLogger) ServiceLogger(n endure.Named) (Logger, error)

NamedLogger returns logger dedicated to the specific channel. Similar to Named() but also reads the core params.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL