log

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

View Source
const (
	OutputModeJson    = "json"
	OutputModeConsole = "console"
)

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

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

func Debugf

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

Debugf uses fmt.Sprintf to log a template message.

func Debugw

func Debugw(keysAndValues []interface{}, msgFormat string, args ...interface{})

Debugw uses fmt.Sprintf to log a template message with extra context value.

func Error

func Error(args ...interface{})

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

func Errorf

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

Errorf uses fmt.Sprintf to log a template message.

func Errorw

func Errorw(keysAndValues []interface{}, msgFormat string, args ...interface{})

Errorw uses fmt.Sprintf to log a template message with extra context value.

func Fatal

func Fatal(args ...interface{})

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

func Fatalf

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

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

func Fatalw

func Fatalw(keysAndValues []interface{}, msgFormat string, args ...interface{})

Fatalw uses fmt.Sprintf to log a template message with extra context value, then calls os.Exit.

func Info

func Info(args ...interface{})

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

func Infof

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

Infof uses fmt.Sprintf to log a template message.

func Infow

func Infow(keysAndValues []interface{}, msgFormat string, args ...interface{})

Infow uses fmt.Sprintf to log a template message with extra context value.

func ReplaceGlobal

func ReplaceGlobal(logger Logger)

ReplaceGlobal Register a logger instance as global

func Warn

func Warn(args ...interface{})

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

func Warnf

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

Warnf uses fmt.Sprintf to log a template message.

func Warnw

func Warnw(keysAndValues []interface{}, msgFormat string, args ...interface{})

Warnw uses fmt.Sprintf to log a template message with extra context value.

Types

type DefaultLogger

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

func NewDefaultLogger

func NewDefaultLogger(options *Options) (*DefaultLogger, error)

func (*DefaultLogger) Clone

func (l *DefaultLogger) Clone(options ...OptionFunc) Logger

func (*DefaultLogger) Debug

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

func (*DefaultLogger) Debugf

func (l *DefaultLogger) Debugf(msgFormat string, args ...interface{})

func (*DefaultLogger) Debugw

func (l *DefaultLogger) Debugw(keysAndValues []interface{}, msgFormat string, args ...interface{})

func (*DefaultLogger) Error

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

func (*DefaultLogger) Errorf

func (l *DefaultLogger) Errorf(msgFormat string, args ...interface{})

func (*DefaultLogger) Errorw

func (l *DefaultLogger) Errorw(keysAndValues []interface{}, msgFormat string, args ...interface{})

func (*DefaultLogger) Fatal

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

func (*DefaultLogger) Fatalf

func (l *DefaultLogger) Fatalf(msgFormat string, args ...interface{})

func (*DefaultLogger) Fatalw

func (l *DefaultLogger) Fatalw(keysAndValues []interface{}, msgFormat string, args ...interface{})

func (*DefaultLogger) Info

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

func (*DefaultLogger) Infof

func (l *DefaultLogger) Infof(msgFormat string, args ...interface{})

func (*DefaultLogger) Infow

func (l *DefaultLogger) Infow(keysAndValues []interface{}, msgFormat string, args ...interface{})

func (*DefaultLogger) Warn

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

func (*DefaultLogger) Warnf

func (l *DefaultLogger) Warnf(msgFormat string, args ...interface{})

func (*DefaultLogger) Warnw

func (l *DefaultLogger) Warnw(keysAndValues []interface{}, msgFormat string, args ...interface{})

type Logger

type Logger interface {
	// Info uses fmt.Sprint to construct and log a message.
	Info(args ...interface{})

	// Infof uses fmt.Sprintf to log a template message.
	Infof(msgFormat string, args ...interface{})

	// Infow uses fmt.Sprintf to log a template message with extra context value.
	Infow(keysAndValues []interface{}, msgFormat string, args ...interface{})

	// Debug uses fmt.Sprint to construct and log a message.
	Debug(args ...interface{})

	// Debugf uses fmt.Sprintf to log a template message.
	Debugf(msgFormat string, args ...interface{})

	// Debugw uses fmt.Sprintf to log a template message with extra context value.
	Debugw(keysAndValues []interface{}, msgFormat string, args ...interface{})

	// Warn uses fmt.Sprint to construct and log a message.
	Warn(args ...interface{})

	// Warnf uses fmt.Sprintf to log a template message.
	Warnf(msgFormat string, args ...interface{})

	// Warnw uses fmt.Sprintf to log a template message with extra context value.
	Warnw(keysAndValues []interface{}, msgFormat string, args ...interface{})

	// Error uses fmt.Sprint to construct and log a message.
	Error(args ...interface{})

	// Errorf uses fmt.Sprintf to log a template message.
	Errorf(msgFormat string, args ...interface{})

	// Errorw uses fmt.Sprintf to log a template message with extra context value.
	Errorw(keysAndValues []interface{}, msgFormat string, args ...interface{})

	// Fatal uses fmt.Sprint to construct and log a message, then calls os.Exit.
	Fatal(args ...interface{})

	// Fatalf uses fmt.Sprintf to log a template message, then calls os.Exit.
	Fatalf(msgFormat string, args ...interface{})

	// Fatalw uses fmt.Sprintf to log a template message with extra context value, then calls os.Exit.
	Fatalw(keysAndValues []interface{}, msgFormat string, args ...interface{})
}

func GetGlobal

func GetGlobal() Logger

GetGlobal Get global logger instance

type OptionFunc

type OptionFunc func(opt *Options)

func AddCallerSkip

func AddCallerSkip(skip int) OptionFunc

type Options

type Options struct {
	// Development puts the logger in development mode, which changes the
	// behavior of DPanicLevel and takes stack traces more liberally.
	Development bool

	// Enable json output mode
	JsonOutputMode bool

	// Skip number of callers before show caller
	CallerSkip int
}

type Properties

type Properties struct {
	Development    bool `default:"false"`
	JsonOutputMode bool `default:"true"`
	CallerSkip     int  `default:"2"`
}

func NewProperties

func NewProperties(loader config.Loader) (*Properties, error)

func (Properties) Prefix

func (l Properties) Prefix() string

type TestingLogger

type TestingLogger struct {
	*DefaultLogger
	// contains filtered or unexported fields
}

func NewTestingLogger

func NewTestingLogger(tb testing.TB, options *Options) (*TestingLogger, error)

func NewTestingLoggerFromDefault

func NewTestingLoggerFromDefault(tb testing.TB, defaultLogger *DefaultLogger) *TestingLogger

type TestingWriter

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

TestingWriter is a WriteSyncer that writes to the given testing.TB.

func NewTestingWriter

func NewTestingWriter(tb testing.TB) TestingWriter

func (TestingWriter) Sync

func (w TestingWriter) Sync() error

func (TestingWriter) Write

func (w TestingWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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