log

package
v2.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 16 Imported by: 10

Documentation

Index

Constants

View Source
const (
	// DebugLevel logs are typically voluminous, and are usually disabled in
	// production.
	DebugLevel = zap.DebugLevel
	// InfoLevel is the default logging priority.
	InfoLevel = zap.InfoLevel
	// WarnLevel logs are more important than Info, but don't need individual
	// human review.
	WarnLevel = zap.WarnLevel
	// ErrorLevel logs are high-priority. If an application is running smoothly,
	// it shouldn't generate any error-level logs.
	ErrorLevel = zap.ErrorLevel
	// DPanicLevel logs are particularly important errors. In development the
	// logger panics after writing the message.
	DPanicLevel = zap.DPanicLevel
	// PanicLevel logs a message, then panics.
	PanicLevel = zap.PanicLevel
	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel = zap.FatalLevel
)

Variables

View Source
var (
	CorrelationIDKey    = "correlationId"
	DeviceIDKey         = "deviceId"
	ResourceHrefKey     = "href"
	CommandFilterKey    = "commandFilter"
	DeviceIDFilterKey   = "deviceIdFilter"
	ResourceIDFilterKey = "resourceIdFilter"
	TypeFilterKey       = "typeFilter"
	EventFilterKey      = "eventFilter"
	SubActionKey        = "subscriptionAction"
	PlgdKey             = "plgd"
	JWTKey              = "jwt"
	SubKey              = "sub"
	RequestKey          = "request"
	ResponseKey         = "response"
	StartTimeKey        = "startTime"
	DeadlineKey         = "deadline"
	MethodKey           = "method"
	ProtocolKey         = "protocol"
	BodyKey             = "body"
	DurationMSKey       = "durationMs"
	ErrorKey            = "error"
	X509Key             = "x509"
	TraceIDKey          = "traceId"
	MessageKey          = "message"
	SubjectsKey         = "subjects"
	CertManagerKey      = "certManager"
	LocalEndpointsKey   = "localEndpoints"
)

Functions

func Debug

func Debug(args ...interface{})

Debug uses fmt.Sprint to construct and log a message.

func Debugf

func Debugf(template string, args ...interface{})

Debugf uses fmt.Sprintf to log a templated message.

func DurationToMilliseconds added in v2.2.4

func DurationToMilliseconds(duration time.Duration) float32

func Error

func Error(args ...interface{})

Error uses fmt.Sprint to construct and log a message.

func Errorf

func Errorf(template string, args ...interface{})

Errorf uses fmt.Sprintf to log a templated message.

func Fatal

func Fatal(args ...interface{})

Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.

func Fatalf

func Fatalf(template string, args ...interface{})

Fatalf uses fmt.Sprintf to log a templated message, then calls os.Exit.

func Info

func Info(args ...interface{})

Info uses fmt.Sprint to construct and log a message.

func Infof

func Infof(template string, args ...interface{})

Infof uses fmt.Sprintf to log a templated message.

func LogAndReturnError

func LogAndReturnError(err error) error

func Set

func Set(logger Logger)

Set logger for global log fuctions

func SetLogValue added in v2.2.4

func SetLogValue(m map[string]interface{}, key string, val interface{})

func Setup

func Setup(config Config)

Setup changes log configuration for the application. Call ASAP in main after parse args/env.

func Warn

func Warn(args ...interface{})

Warn uses fmt.Sprint to construct and log a message.

func Warnf

func Warnf(template string, args ...interface{})

Warnf uses fmt.Sprintf to log a templated message.

Types

type Config

type Config struct {
	// Level is the minimum enabled logging level. Note that this is a dynamic
	// level, so calling Config.Level.SetLevel will atomically change the log
	// level of all loggers descended from this config.
	Level zapcore.Level `json:"level" yaml:"level"`
	// Encoding sets the logger's encoding. Valid values are "json" (default) and
	// "console", as well as any third-party encodings registered via
	// RegisterEncoder.
	Encoding   string           `json:"encoding" yaml:"encoding"`
	Stacktrace StacktraceConfig `json:"stacktrace" yaml:"stacktrace"`
	// An EncoderConfig allows users to configure the concrete encoders supplied by
	// zapcore.
	EncoderConfig EncoderConfig `json:"encoderConfig" yaml:"encoderConfig"`

	// DumpBody if true, dump request/response/stream body to log.
	DumpBody bool `json:"dumpBody" yaml:"dumpBody"`
}

Config configuration for setup logging.

func MakeDefaultConfig added in v2.2.4

func MakeDefaultConfig() Config

func (*Config) Validate added in v2.2.4

func (c *Config) Validate() error

type DTLSLogger added in v2.6.0

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

func (DTLSLogger) Debug added in v2.6.0

func (l DTLSLogger) Debug(msg string)

func (DTLSLogger) Debugf added in v2.6.0

func (l DTLSLogger) Debugf(format string, args ...interface{})

func (DTLSLogger) Error added in v2.6.0

func (l DTLSLogger) Error(msg string)

func (DTLSLogger) Errorf added in v2.6.0

func (l DTLSLogger) Errorf(format string, args ...interface{})

func (DTLSLogger) Info added in v2.6.0

func (l DTLSLogger) Info(msg string)

func (DTLSLogger) Infof added in v2.6.0

func (l DTLSLogger) Infof(format string, args ...interface{})

func (DTLSLogger) Trace added in v2.6.0

func (l DTLSLogger) Trace(msg string)

func (DTLSLogger) Tracef added in v2.6.0

func (l DTLSLogger) Tracef(format string, args ...interface{})

func (DTLSLogger) Warn added in v2.6.0

func (l DTLSLogger) Warn(msg string)

func (DTLSLogger) Warnf added in v2.6.0

func (l DTLSLogger) Warnf(format string, args ...interface{})

type DTLSLoggerFactory added in v2.6.0

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

func (DTLSLoggerFactory) NewLogger added in v2.6.0

func (f DTLSLoggerFactory) NewLogger(scope string) logging.LeveledLogger

type EncoderConfig added in v2.2.4

type EncoderConfig struct {
	EncodeTime TimeEncoderWrapper `json:"timeEncoder" yaml:"timeEncoder"`
}

type EpochMillisTimeEncoder added in v2.2.4

type EpochMillisTimeEncoder struct{}

func (EpochMillisTimeEncoder) Encode added in v2.2.4

func (EpochMillisTimeEncoder) String added in v2.2.4

func (e EpochMillisTimeEncoder) String() string

func (EpochMillisTimeEncoder) TimeString added in v2.2.4

func (e EpochMillisTimeEncoder) TimeString() string

type EpochNanosTimeEncoder added in v2.2.4

type EpochNanosTimeEncoder struct{}

func (EpochNanosTimeEncoder) Encode added in v2.2.4

func (EpochNanosTimeEncoder) String added in v2.2.4

func (e EpochNanosTimeEncoder) String() string

func (EpochNanosTimeEncoder) TimeString added in v2.2.4

func (e EpochNanosTimeEncoder) TimeString() string

type EpochTimeEncoder added in v2.2.4

type EpochTimeEncoder struct{}

func (EpochTimeEncoder) Encode added in v2.2.4

func (EpochTimeEncoder) String added in v2.2.4

func (e EpochTimeEncoder) String() string

func (EpochTimeEncoder) TimeString added in v2.2.4

func (e EpochTimeEncoder) TimeString() string

type ISO8601TimeEncoder added in v2.2.4

type ISO8601TimeEncoder struct{}

func (ISO8601TimeEncoder) Encode added in v2.2.4

func (ISO8601TimeEncoder) String added in v2.2.4

func (e ISO8601TimeEncoder) String() string

func (ISO8601TimeEncoder) TimeString added in v2.2.4

func (e ISO8601TimeEncoder) TimeString() string

type Logger

type Logger interface {
	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	Fatal(args ...interface{})
	Debugf(template string, args ...interface{})
	Infof(template string, args ...interface{})
	Warnf(template string, args ...interface{})
	Errorf(template string, args ...interface{})
	Fatalf(template string, args ...interface{})
	With(args ...interface{}) Logger
	Unwrap() interface{}
	LogAndReturnError(err error) error
	Config() Config
	Check(lvl zapcore.Level) bool
	GetLogFunc(lvl zapcore.Level) func(args ...interface{})
	DTLSLoggerFactory() logging.LoggerFactory
}

func Get

func Get() Logger

type RFC3339NanoTimeEncoder added in v2.2.4

type RFC3339NanoTimeEncoder struct{}

func (RFC3339NanoTimeEncoder) Encode added in v2.2.4

func (RFC3339NanoTimeEncoder) String added in v2.2.4

func (e RFC3339NanoTimeEncoder) String() string

func (RFC3339NanoTimeEncoder) TimeString added in v2.2.4

func (e RFC3339NanoTimeEncoder) TimeString() string

type RFC3339TimeEncoder added in v2.2.4

type RFC3339TimeEncoder struct{}

func (RFC3339TimeEncoder) Encode added in v2.2.4

func (RFC3339TimeEncoder) String added in v2.2.4

func (e RFC3339TimeEncoder) String() string

func (RFC3339TimeEncoder) TimeString added in v2.2.4

func (e RFC3339TimeEncoder) TimeString() string

type StacktraceConfig added in v2.2.4

type StacktraceConfig struct {
	Enabled bool          `yaml:"enabled" json:"enabled" description:"enable stacktrace"`
	Level   zapcore.Level `json:"level" yaml:"level" description:"from level"`
}

func (*StacktraceConfig) Validate added in v2.2.4

func (c *StacktraceConfig) Validate() error

type TimeEncoder added in v2.2.4

type TimeEncoder interface {
	Encode(time.Time, zapcore.PrimitiveArrayEncoder)
	String() string
	TimeString() string
}

type TimeEncoderWrapper added in v2.2.4

type TimeEncoderWrapper struct {
	TimeEncoder TimeEncoder
}

func (TimeEncoderWrapper) MarshalText added in v2.2.4

func (t TimeEncoderWrapper) MarshalText() ([]byte, error)

func (*TimeEncoderWrapper) UnmarshalText added in v2.2.4

func (t *TimeEncoderWrapper) UnmarshalText(text []byte) error

type WrapSuggarLogger added in v2.3.9

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

func NewLogger

func NewLogger(config Config) *WrapSuggarLogger

NewLogger creates logger

func (*WrapSuggarLogger) Check added in v2.3.9

func (l *WrapSuggarLogger) Check(lvl zapcore.Level) bool

func (*WrapSuggarLogger) Config added in v2.3.9

func (l *WrapSuggarLogger) Config() Config

func (*WrapSuggarLogger) DTLSLoggerFactory added in v2.6.0

func (l *WrapSuggarLogger) DTLSLoggerFactory() logging.LoggerFactory

func (*WrapSuggarLogger) Debug added in v2.3.9

func (l *WrapSuggarLogger) Debug(args ...interface{})

func (*WrapSuggarLogger) Debugf added in v2.3.9

func (l *WrapSuggarLogger) Debugf(template string, args ...interface{})

func (*WrapSuggarLogger) Error added in v2.3.9

func (l *WrapSuggarLogger) Error(args ...interface{})

func (*WrapSuggarLogger) Errorf added in v2.3.9

func (l *WrapSuggarLogger) Errorf(template string, args ...interface{})

Errorf uses fmt.Sprintf to log a templated message.

func (*WrapSuggarLogger) Fatal added in v2.3.9

func (l *WrapSuggarLogger) Fatal(args ...interface{})

func (*WrapSuggarLogger) Fatalf added in v2.3.9

func (l *WrapSuggarLogger) Fatalf(template string, args ...interface{})

func (*WrapSuggarLogger) GetLogFunc added in v2.7.5

func (l *WrapSuggarLogger) GetLogFunc(lvl zapcore.Level) func(args ...interface{})

func (*WrapSuggarLogger) Info added in v2.3.9

func (l *WrapSuggarLogger) Info(args ...interface{})

func (*WrapSuggarLogger) Infof added in v2.3.9

func (l *WrapSuggarLogger) Infof(template string, args ...interface{})

func (*WrapSuggarLogger) LogAndReturnError added in v2.3.9

func (l *WrapSuggarLogger) LogAndReturnError(err error) error

func (*WrapSuggarLogger) PreProcessArgs added in v2.5.0

func (l *WrapSuggarLogger) PreProcessArgs(args ...interface{}) *WrapSuggarLogger

func (*WrapSuggarLogger) Unwrap added in v2.3.9

func (l *WrapSuggarLogger) Unwrap() interface{}

func (*WrapSuggarLogger) Warn added in v2.3.9

func (l *WrapSuggarLogger) Warn(args ...interface{})

func (*WrapSuggarLogger) Warnf added in v2.3.9

func (l *WrapSuggarLogger) Warnf(template string, args ...interface{})

func (*WrapSuggarLogger) With added in v2.3.9

func (l *WrapSuggarLogger) With(args ...interface{}) Logger

Jump to

Keyboard shortcuts

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