go_logger

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

README

go-logger

Simple logger used mostly in Randlabs.IO apps

Documentation

Index

Constants

View Source
const (
	LogLevelQuiet   LogLevel = 0
	LogLevelError            = 1
	LogLevelWarning          = 2
	LogLevelInfo             = 3
	LogLevelDebug            = 4
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorHandler added in v1.2.0

type ErrorHandler func(message string)

ErrorHandler is a callback to call if an internal error must be notified.

type FileOptions added in v1.2.0

type FileOptions file.Options

FileOptions specifies the file logger settings.

type LogLevel added in v1.2.0

type LogLevel uint

LogLevel defines the level of message verbosity.

type Logger added in v1.2.0

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

Logger is the object that controls logging.

func Create added in v1.2.0

func Create(options Options) (*Logger, error)

Create creates a new logger.

func Default added in v1.2.0

func Default() *Logger

Default returns a logger that only outputs error and warnings to the console.

func (*Logger) Debug added in v1.2.0

func (logger *Logger) Debug(level uint, obj interface{})

Debug emits a debug message into the configured targets. If a string is passed, output format will be in DATE [LEVEL] MESSAGE. If a struct is passed, output will be in json with level and timestamp fields automatically added.

func (*Logger) Destroy added in v1.2.0

func (logger *Logger) Destroy()

Destroy shuts down the logger.

func (*Logger) Error added in v1.2.0

func (logger *Logger) Error(obj interface{})

Error emits an error message into the configured targets. If a string is passed, output format will be in DATE [LEVEL] MESSAGE. If a struct is passed, output will be in json with level and timestamp fields automatically added.

func (*Logger) Info added in v1.2.0

func (logger *Logger) Info(obj interface{})

Info emits an information message into the configured targets. If a string is passed, output format will be in DATE [LEVEL] MESSAGE. If a struct is passed, output will be in json with level and timestamp fields automatically added.

func (*Logger) SetDebugLevel added in v1.2.0

func (logger *Logger) SetDebugLevel(newLevel uint)

SetDebugLevel sets the minimum level for debug messages.

func (*Logger) SetLevel added in v1.2.0

func (logger *Logger) SetLevel(newLevel LogLevel)

SetLevel sets the minimum level for all messages.

func (*Logger) Warning added in v1.2.0

func (logger *Logger) Warning(obj interface{})

Warning emits a warning message into the configured targets. If a string is passed, output format will be in DATE [LEVEL] MESSAGE. If a struct is passed, output will be in json with level and timestamp fields automatically added.

type Options

type Options struct {
	// Disable console output.
	DisableConsole bool `json:"disableConsole,omitempty"`

	// Optionally enable file logging and establish its settings.
	FileLog *FileOptions `json:"fileLog,omitempty"`

	// Optionally enable syslog logging and establish its settings.
	SysLog *SyslogOptions `json:"sysLog,omitempty"`

	// Set the initial logging level to use.
	Level LogLevel `json:"level,omitempty"`

	// Set the initial logging level for debug output to use.
	DebugLevel uint `json:"debugLevel,omitempty"`

	// Use the local computer time instead of UTC.
	UseLocalTime bool `json:"useLocalTime,omitempty"`

	// A callback to call if an internal error is encountered.
	ErrorHandler ErrorHandler
}

Options specifies the logger settings to use when initialized.

type SyslogOptions added in v1.2.0

type SyslogOptions syslog.Options

SyslogOptions specifies the syslog logger settings.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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