logger

package
v0.1.0-M4 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: Apache-2.0, EPL-2.0 Imports: 12 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigMQTT

func ConfigMQTT(level LogLevel, logger *log.Logger)

ConfigMQTT sets level for paho MQTT logging

Types

type Exporter

type Exporter interface {
	Export(level LogLevel, msg string)
}

Exporter interface allows customization of log target.

type LogLevel

type LogLevel int

LogLevel defines the logger levels.

const (
	// ERROR is used to define the errors logging level.
	ERROR LogLevel = 1 + iota
	// WARN is used to define the errors and warnings logging level.
	WARN
	// INFO is used to define the errors, warnings and information logging level.
	INFO
	// DEBUG is used to define the errors, warnings, information and debug logging level.
	DEBUG
	// TRACE is used to define the more detailed logging level.
	TRACE
)

func ParseLogLevel

func ParseLogLevel(level string) LogLevel

ParseLogLevel returns a LogLevel for a level string representation.

func (LogLevel) Enabled

func (l LogLevel) Enabled(level LogLevel) bool

Enabled returns true if the level is enabled.

func (LogLevel) MarshalJSON

func (l LogLevel) MarshalJSON() ([]byte, error)

MarshalJSON is used to marshal LogLevel.

func (LogLevel) String

func (l LogLevel) String() string

func (LogLevel) StringAligned

func (l LogLevel) StringAligned() string

StringAligned returns the log level as string with padding.

func (*LogLevel) UnmarshalJSON

func (l *LogLevel) UnmarshalJSON(b []byte) error

UnmarshalJSON is used to unmarshal LogLevel.

type LogLevelDecorator

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

LogLevelDecorator is responsible for printing declaration depending on the level.

func NewLevelDecorator

func NewLevelDecorator(logger *log.Logger, level LogLevel) LogLevelDecorator

NewLevelDecorator creates decorator for given logger and level instances.

func NewLevelDecoratorWithExporter

func NewLevelDecoratorWithExporter(exporter Exporter, level LogLevel) LogLevelDecorator

NewLevelDecoratorWithExporter creates log level decorator with specified exporter.

func (LogLevelDecorator) Printf

func (l LogLevelDecorator) Printf(format string, v ...interface{})

Printf formats the text while printing the data.

func (LogLevelDecorator) Println

func (l LogLevelDecorator) Println(v ...interface{})

Println prints the values with a new line break.

type LogSettings

type LogSettings struct {
	LogFile       string   `json:"logFile"`
	LogLevel      LogLevel `json:"logLevel"`
	LogFileSize   int      `json:"logFileSize"`
	LogFileCount  int      `json:"logFileCount"`
	LogFileMaxAge int      `json:"logFileMaxAge"`
}

LogSettings defines the Logger configuration.

func (*LogSettings) Validate

func (c *LogSettings) Validate() error

Validate validates the Logger settings.

type Logger

type Logger interface {
	watermill.LoggerAdapter

	IsDebugEnabled() bool

	IsTraceEnabled() bool

	Warn(msg string, err error, fields watermill.LogFields)

	Errorf(format string, a ...interface{})
	Warnf(format string, a ...interface{})
	Infof(format string, a ...interface{})
	Debugf(format string, a ...interface{})
	Tracef(format string, a ...interface{})
}

Logger interface enables the loging functionality.

func NewLogger

func NewLogger(logger *log.Logger, level LogLevel) Logger

NewLogger creates a Logger instance.

func NewLoggerWithExporter

func NewLoggerWithExporter(exporter Exporter, level LogLevel) Logger

NewLoggerWithExporter creates a Logger instance with specified exporter.

func Setup

func Setup(name string, settings *LogSettings) (io.WriteCloser, Logger)

Setup creates the logger instance with provided name and settings.

Jump to

Keyboard shortcuts

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