modlog

package
v0.1.6-0...-5c25bcb Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SwitchLogOutputToBuffer

func SwitchLogOutputToBuffer(logger Logger)

SwitchLogOutputToBuffer switches log output to test buffer. Should only be used for testing.

func VerifyCustomLogger

func VerifyCustomLogger(t *testing.T, logger Logger, module string)

VerifyCustomLogger verifies custom logging behaviour. Should only be used for tests.

func VerifyDefaultLogging

func VerifyDefaultLogging(t *testing.T, logger Logger, module string, setLevel func(module string, level metadata.Level))

VerifyDefaultLogging verifies default logging behaviour. Should only be used for tests.

Types

type DefLog

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

DefLog is a logger implementation built on top of standard go log. There is a configurable caller info feature which displays caller function information name in logged lines. caller info can be configured by log levels and modules. By default it is enabled. Log Format : [<MODULE NAME>] <TIME IN UTC> - <CALLER INFO> -> <LOG LEVEL> <LOG TEXT>.

func NewDefLog

func NewDefLog(module string) *DefLog

NewDefLog returns new DefLog instance based on given module.

func (*DefLog) Debugf

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

Debugf calls go 'log.Output' and can be used for logging verbose messages. Arguments are handled in the manner of fmt.Printf.

func (*DefLog) Errorf

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

Errorf calls go 'log.Output' and can be used for logging errors. Arguments are handled in the manner of fmt.Printf.

func (*DefLog) Fatalf

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

Fatalf is CRITICAL log formatted followed by a call to os.Exit(1).

func (*DefLog) Infof

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

Infof calls go 'log.Output' and can be used for logging general information messages. INFO is default logging level Arguments are handled in the manner of fmt.Printf.

func (*DefLog) Panicf

func (l *DefLog) Panicf(format string, args ...interface{})

Panicf is CRITICAL log formatted followed by a call to panic().

func (*DefLog) SetOutput

func (l *DefLog) SetOutput(output io.Writer)

SetOutput sets the output destination for the logger.

func (*DefLog) Warnf

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

Warnf calls go log.Output and can be used for logging possible errors. Arguments are handled in the manner of fmt.Printf.

type Logger

type Logger interface {

	// Fatalf is critical fatal logging, should possibly followed by a call to os.Exit(1)
	Fatalf(msg string, args ...interface{})

	// Panicf is critical logging, should possibly followed by panic
	Panicf(msg string, args ...interface{})

	// Debugf is for logging verbose messages
	Debugf(msg string, args ...interface{})

	// Infof for logging general logging messages
	Infof(msg string, args ...interface{})

	// Warnf is for logging messages about possible issues
	Warnf(msg string, args ...interface{})

	// Errorf is for logging errors
	Errorf(msg string, args ...interface{})
}

Logger - Standard logger interface.

type ModLog

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

ModLog is a moduled wrapper for any underlying 'log.Logger' implementation. Since this is a moduled wrapper each module can have different logging levels (default is INFO).

func NewModLog

func NewModLog(logger Logger, module string) *ModLog

NewModLog returns new moduled logger instance based on given logger implementation and module.

func (*ModLog) Debugf

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

Debugf calls error log function if DEBUG level enabled.

func (*ModLog) Errorf

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

Errorf calls error log function if ERROR level enabled.

func (*ModLog) Fatalf

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

Fatalf calls underlying logger.Fatal.

func (*ModLog) Infof

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

Infof calls error log function if INFO level enabled.

func (*ModLog) Panicf

func (m *ModLog) Panicf(format string, args ...interface{})

Panicf calls underlying logger.Panic.

func (*ModLog) Warnf

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

Warnf calls error log function if WARNING level enabled.

type SampleLog

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

SampleLog is a sample logger implementation for testing purposes. note: this implementation should be strictly used for testing only.

func GetSampleCustomLogger

func GetSampleCustomLogger(module string) *SampleLog

GetSampleCustomLogger returns custom logger which can only be used for testing purposes.

func (*SampleLog) Debugf

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

Debugf calls error log function if DEBUG level enabled.

func (*SampleLog) Errorf

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

Errorf calls error log function if ERROR level enabled.

func (*SampleLog) Fatalf

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

Fatalf calls underlying logger.Fatalf.

func (*SampleLog) Infof

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

Infof calls error log function if INFO level enabled.

func (*SampleLog) Panicf

func (m *SampleLog) Panicf(format string, args ...interface{})

Panicf calls underlying logger.Panicf.

func (*SampleLog) Warnf

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

Warnf calls error log function if WARNING level enabled.

Jump to

Keyboard shortcuts

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