log

package
v0.0.0-...-20679a4 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Header is the print format for log. It is used
	// to include/exclude the fields in json output.
	Header = `{"time":"${time_rfc3339}","level":"${level}"}`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	// Level is the log level for logging data.
	Level LevelType

	// Output is the log writer such as Stdout, Buffer, File etc.
	Output io.Writer

	// Color is to enable/disable output in colored mode.
	Color bool
}

Configuration is the config info for initializing new logger.

type LevelType

type LevelType uint8

LevelType is the log level type.

const (
	// LevelTypeDebug is representing 'Debug' value for log level type.
	LevelTypeDebug LevelType = iota

	// LevelTypeInfo is representing 'Info' value for log level type.
	LevelTypeInfo

	// LevelTypeWarn is representing 'Warn' value for log level type.
	LevelTypeWarn

	// LevelTypeError is representing 'Error' value for log level type.
	LevelTypeError
)

type Logger

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

Logger is the logger struct.

func New

func New(config Configuration) *Logger

New creates a new instance of logger.

func (*Logger) Debug

func (l *Logger) Debug(value string)

Debug writes the logs on the configured output. If the log level is higher than DEBUG, log writing is ignored.

func (*Logger) Error

func (l *Logger) Error(value string, err error)

Error writes the logs on the configured output. If the log level is higher than ERROR, log writing is ignored.

func (*Logger) Fatal

func (l *Logger) Fatal(value string, err error)

Fatal writes the logs on the configured output and exits the process with 0 error code.

func (*Logger) Info

func (l *Logger) Info(value string)

Info writes the logs on the configured output. If the log level is higher than INFO, log writing is ignored.

func (*Logger) Warn

func (l *Logger) Warn(value string)

Warn writes the logs on the configured output. If the log level is higher than WARN, log writing is ignored.

Jump to

Keyboard shortcuts

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