log

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2022 License: Apache-2.0 Imports: 13 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BodyKey = "body"
View Source
var CommandFilterKey = "commandFilter"
View Source
var CorrelationIDKey = "correlationId"
View Source
var DeadlineKey = "deadline"
View Source
var DeviceIDFilterKey = "deviceIdFilter"
View Source
var DeviceIDKey = "deviceId"
View Source
var DurationMSKey = "durationMs"
View Source
var EventFilterKey = "eventFilter"
View Source
var JWTKey = "jwt"
View Source
var JWTSubKey = "jwt.sub"
View Source
var MethodKey = "method"
View Source
var PlgdKey = "plgd"
View Source
var ProtocolKey = "protocol"
View Source
var RequestKey = "request"
View Source
var ResourceHrefKey = "href"
View Source
var ResourceIDFilterKey = "resourceIdFilter"
View Source
var ResponseKey = "response"
View Source
var StartTimeKey = "startTime"
View Source
var SubActionKey = "subscriptionAction"
View Source
var SubKey = "sub"
View Source
var TypeFilterKey = "typeFilter"

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"`
}

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 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
}

func Get

func Get() Logger

func NewLogger

func NewLogger(config Config) Logger

NewLogger creates 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 (e *TimeEncoderWrapper) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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