logger

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// output overrides default logging to os.Stderr
	Output io.Writer
	// setting with log-level should be written to output. (default: Info)
	LogLevel Level
	// enable colored logging to console, otherwise use JSON logger. (default: false)
	EnableConsoleLogger bool

	// WithCaller logs the path and linenumber of the caller.
	// This should not be used in production
	WithCaller bool
	// ErrorFieldName is the label for Go errors in the JSON output. (default: error)
	ErrorFieldName string
	// contains filtered or unexported fields
}

Config configured the logging.

type CustomLogger added in v0.1.8

type CustomLogger struct {
	zerolog.Logger
}

CustomLogger implements the estransport.Logger interface.

func NewLogger

func NewLogger(cfg Config) CustomLogger

NewLogger creates zerolog.Logger with sensible defaults

func Nop added in v0.3.0

func Nop() CustomLogger

func (*CustomLogger) LogRoundTrip added in v0.1.8

func (l *CustomLogger) LogRoundTrip(
	req *http.Request,
	res *http.Response,
	err error,
	start time.Time,
	dur time.Duration,
) error

LogRoundTrip prints the information about request and response.

func (*CustomLogger) RequestBodyEnabled added in v0.1.8

func (l *CustomLogger) RequestBodyEnabled() bool

RequestBodyEnabled makes the client pass request body to logger

func (*CustomLogger) ResponseBodyEnabled added in v0.1.8

func (l *CustomLogger) ResponseBodyEnabled() bool

ResponseBodyEnabled makes the client pass response body to logger

type Level

type Level int8

Level defines log levels.

const (
	// DebugLevel defines debug log level.
	DebugLevel Level = iota
	// InfoLevel defines info log level.
	InfoLevel
	// WarnLevel defines warn log level.
	WarnLevel
	// ErrorLevel defines error log level.
	ErrorLevel
	// FatalLevel defines fatal log level.
	FatalLevel
	// PanicLevel defines panic log level.
	PanicLevel
	// NoLevel defines an absent log level.
	NoLevel
	// Disabled disables the logger.
	Disabled

	// TraceLevel defines trace log level.
	TraceLevel Level = -1
)

func ParseLogLevel

func ParseLogLevel(level string) Level

type WrapDebug

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

func NewWrapDebug

func NewWrapDebug(logger *zerolog.Logger) *WrapDebug

func (*WrapDebug) Printf

func (w *WrapDebug) Printf(format string, vars ...interface{})

type WrapError

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

func NewWrapError

func NewWrapError(logger *zerolog.Logger) *WrapError

func (*WrapError) Printf

func (w *WrapError) Printf(format string, vars ...interface{})

type WrapInfo

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

func NewWrapInfo

func NewWrapInfo(logger *zerolog.Logger) *WrapInfo

func (*WrapInfo) Printf

func (w *WrapInfo) Printf(format string, vars ...interface{})

type WrapTrace

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

func NewWrapTrace

func NewWrapTrace(logger *zerolog.Logger) *WrapTrace

func (*WrapTrace) Printf

func (w *WrapTrace) Printf(format string, vars ...interface{})

Jump to

Keyboard shortcuts

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