logger

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const LOG_LEVEL_ALL int = 0
View Source
const LOG_LEVEL_INFO int = 1
View Source
const LOG_LEVEL_NONE int = 3
View Source
const LOG_LEVEL_WARN int = 2

Variables

View Source
var NilLogger = &nilLogger{}

Functions

This section is empty.

Types

type ColorLogger

type ColorLogger struct {
	// Verbose must be set to true in order for Trace log messages to be emitted.
	Verbose bool

	// Level is the threshold for this ColorLogger.
	//
	// Logging messages which are less severe than level will be ignored.
	//
	// Logging messages with a severity equal or greater than level will be emitted.
	//
	// Levels are represented numerically, with 0 being the most "severe" and 3 being the least "severe".
	//
	// When Level is set to LOG_LEVEL_NONE (3), no messages will be emitted.
	//
	// When Level is set to LOG_LEVEL_ALL, all messages except for Trace messages will be emitted.
	//
	// In order for Trace messages to be emitted, Level must be set to LOG_LEVEL_ALL, and Verbose must be set to true.
	Level int

	// Prefix is intended to be the name of the entity emitting the log messages.
	// The prefix is prepended to the beginning of every log message.
	Prefix string

	// Color is a boolean flag indicating whether colored output is enabled (true) or not (false).
	Color bool

	// LogTypePrefix is a bool flag that, when true, instructs the logger to also prepend the type of
	// a given log message (e.g., "ERROR", "WARNING", "DEBUG", "TRACE", or "INFO") to the beginning of
	// the message when emitting it.
	LogTypePrefix bool
}

ColorLogger - A Logger that logs to stdout in color

func (*ColorLogger) Debug

func (logger *ColorLogger) Debug(format string, args ...interface{})

Debug - Log a debug message

func (*ColorLogger) Error

func (logger *ColorLogger) Error(format string, args ...interface{})

Error - Log a error

func (*ColorLogger) GetLevel

func (logger *ColorLogger) GetLevel() int

Warn - no-op

func (*ColorLogger) Info

func (logger *ColorLogger) Info(format string, args ...interface{})

Info - Log a general message

func (*ColorLogger) Trace

func (logger *ColorLogger) Trace(format string, args ...interface{})

Trace - Log a very verbose trace message

func (*ColorLogger) Warn

func (logger *ColorLogger) Warn(format string, args ...interface{})

Warn - Log a warning

type DefaultLogger

type DefaultLogger ColorLogger

DefaultLogger - Default monocolor logger.

type Func

type Func func() string

Func Function wrapper that support lazy evaluation for the logger

func NewFormatFunc

func NewFormatFunc(f func(msg string, arg ...interface{}) string, msg string, args ...interface{}) Func

NewFormatFunc Create the function wrapper that compatible with fmt.Sprintf

func NewFunc

func NewFunc(f Func) Func

NewFunc Create the function wrapper for func() string

func NewFuncWithArg

func NewFuncWithArg(f func(arg interface{}) string, arg interface{}) Func

NewFuncWithArg Create the function wrapper for func(arg interface{}) string

func NewFuncWithArgs

func NewFuncWithArgs(f func(arg ...interface{}) string, args ...interface{}) Func

NewFuncWithArgs Create the function wrapper for func(arg ...interface{}) string

func (Func) String

func (f Func) String() string

type Logger

type Logger interface {
	Trace(format string, args ...interface{})
	Debug(format string, args ...interface{})
	Info(format string, args ...interface{})
	Warn(format string, args ...interface{})
	Error(format string, args ...interface{})
	GetLevel() int
}

Logger - Interface to pass into Proxy for it to log messages

Jump to

Keyboard shortcuts

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