logger

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyZapLoggerWithOptions

func ApplyZapLoggerWithOptions(opts *Options)

func Debug

func Debug(msg string, fields ...zap.Field)

func Debugf

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

func Error

func Error(msg string, fields ...zap.Field)

func Errorf

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

func Fatal

func Fatal(msg string, fields ...zap.Field)

func Fatalf

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

func FlushLogs

func FlushLogs()

func Info

func Info(msg string, fields ...zap.Field)

func Infof

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

func IntoContext

func IntoContext(ctx context.Context, l Logging) context.Context

func SetFilter

func SetFilter(filter LogFilter)

func Warn

func Warn(msg string, fields ...zap.Field)

func Warnf

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

func ZapLogger

func ZapLogger(name string) *zap.Logger

Types

type EncodeType

type EncodeType int8

A EncodeType is a logging priority. Higher levels are more important.

const (
	// ConsoleEncode logs are typically voluminous, and are usually disabled in
	// production.
	ConsoleEncode EncodeType = iota + 1
	// JSONEncode is the default logging priority.
	JSONEncode
)

func (*EncodeType) Get

func (l *EncodeType) Get() interface{}

Get gets the level for the flag.Getter interface.

func (EncodeType) MarshalText

func (l EncodeType) MarshalText() ([]byte, error)

MarshalText marshals the Level to text. Note that the text representation drops the -Level suffix (see example).

func (*EncodeType) Set

func (l *EncodeType) Set(s string) error

Set sets the level for the flag.Value interface.

func (EncodeType) String

func (l EncodeType) String() string

String returns a lower-case ASCII representation of the log level.

func (*EncodeType) UnmarshalText

func (l *EncodeType) UnmarshalText(text []byte) error

UnmarshalText unmarshals text to a level. Like MarshalText, UnmarshalText expects the text representation of a Level to drop the -Level suffix (see example).

In particular, this makes it easy to configure logging levels using YAML, TOML, or JSON files.

type Log

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

func (Log) Debug

func (l Log) Debug(msg string, fields ...zap.Field)

func (Log) Debugf

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

func (Log) Error

func (l Log) Error(msg string, fields ...zap.Field)

func (Log) Errorf

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

func (Log) Fatal

func (l Log) Fatal(msg string, fields ...zap.Field)

func (Log) Fatalf

func (l Log) Fatalf(format string, args ...interface{})

func (Log) Info

func (l Log) Info(msg string, fields ...zap.Field)

func (Log) Infof

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

func (Log) Warn

func (l Log) Warn(msg string, fields ...zap.Field)

func (Log) Warnf

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

func (Log) WithFields

func (l Log) WithFields(fields ...zap.Field) Logging

func (Log) WithName

func (l Log) WithName(name string) Logging

type LogFilter

type LogFilter interface {
	Filter(args []interface{}) []interface{}
	FilterF(format string, args []interface{}) (string, []interface{})
}

LogFilter is a collection of functions that can filter all logging calls, e.g. for sanitization of arguments and prevent accidental leaking of secrets.

type Logging

type Logging interface {
	Debug(msg string, fields ...zap.Field)
	Info(msg string, fields ...zap.Field)
	Warn(msg string, fields ...zap.Field)
	Error(msg string, fields ...zap.Field)
	Fatal(msg string, fields ...zap.Field)
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	WithName(name string) Logging
	WithFields(fields ...zap.Field) Logging
}

func FromContext

func FromContext(ctx context.Context) Logging

func WithName

func WithName(name string) Logging

type Options

type Options struct {
	LogFile          string `json:"logFile" yaml:"logFile"`
	LogFileMaxSizeMB int    `json:"logFileMaxSizeMB" yaml:"logFileMaxSizeMB"`
	ToStderr         bool   `json:"toStderr" yaml:"toStderr"`
	Level            string `json:"level" yaml:"level"`
	EncodeType       string `json:"encodeType" yaml:"encodeType"`
	MaxBackups       int    `json:"maxBackups" yaml:"maxBackups"`
	MaxAge           int    `json:"maxAge" yaml:"maxAge"`
	Compress         bool   `json:"compress" yaml:"compress"`
	UseLocalTimeBack bool   `json:"useLocalTime" yaml:"useLocalTime"`
}

func NewLogOptions

func NewLogOptions() *Options

func (*Options) AddFlags

func (s *Options) AddFlags(fs *pflag.FlagSet)

func (*Options) Validate

func (s *Options) Validate() []error

Jump to

Keyboard shortcuts

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