log

package
v1.15.22 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: MIT Imports: 7 Imported by: 39

Documentation

Index

Constants

View Source
const (
	LevelAlert = iota
	LevelError
	LevelWarning
	LevelInfo
	LevelDebug
)

Log level

View Source
const (
	TargetStderr = iota
	TargetSyslog
	TargetLogfile
	TargetStdout
	TargetStdOutAndLogFile
)

Log target

View Source
const (
	// LogPath is the path where log files are stored.
	LogPath = "/var/log/"
)

Variables

This section is empty.

Functions

func Close

func Close()

func Debugf

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

func Errorf

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

func GetLogDirectory

func GetLogDirectory() string

func Logf

func Logf(format string, args ...interface{})

Logf logs to the local log.

func Printf

func Printf(format string, args ...interface{})

Printf logs to the local log and send the log through the channel.

func Request

func Request(tag string, request interface{}, err error)

func Response

func Response(tag string, response interface{}, returnCode int, returnStr string, err error)

func SetLevel

func SetLevel(level int)

func SetLogFileLimits

func SetLogFileLimits(maxFileSize int, maxFileCount int)

func SetName

func SetName(name string)

func SetTargetLogDirectory

func SetTargetLogDirectory(target int, logDirectory string) error

Types

type Logger

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

Logger object

func GetStd

func GetStd() *Logger

GetStd - Helper functions for the standard logger.

func NewLogger deprecated

func NewLogger(name string, level, target int, logDir string) *Logger

NewLogger creates a new Logger.

Deprecated: use NewLoggerE instead

func NewLoggerE

func NewLoggerE(name string, level, target int, logDir string) (*Logger, error)

NewLoggerE creates a new Logger and surfaces any errors encountered during the process. The returned logger is guaranteed to be safe to use when a non-nil error is returned, but may have undesired behavior. Callers should treat the logger as nil under error conditions unless necessary for backwards compatibility reasons.

func (*Logger) Close

func (logger *Logger) Close()

Close closes the log stream.

func (*Logger) Debugf

func (logger *Logger) Debugf(format string, args ...interface{})

Debugf logs a formatted string at info level.

func (*Logger) Errorf

func (logger *Logger) Errorf(format string, args ...interface{})

Errorf logs a formatted string at info level and sends the string to TelemetryBuffer.

func (*Logger) GetLogDirectory

func (logger *Logger) GetLogDirectory() string

GetLogDirectory gets the directory location where logs should be stored.

func (*Logger) Logf

func (logger *Logger) Logf(format string, args ...interface{})

Logf wraps logf.

func (*Logger) Printf

func (logger *Logger) Printf(format string, args ...interface{})

Printf logs a formatted string at info level.

func (*Logger) Request

func (logger *Logger) Request(tag string, request interface{}, err error)

Request logs a structured request.

func (*Logger) Response

func (logger *Logger) Response(tag string, response interface{}, returnCode int, returnStr string, err error)

Response logs a structured response.

func (*Logger) ResponseEx

func (logger *Logger) ResponseEx(tag string, request interface{}, response interface{}, returnCode int, returnStr string, err error)

ResponseEx logs a structured response and the request associate with it.

func (*Logger) SetLevel

func (logger *Logger) SetLevel(level int)

SetLevel sets the log chattiness.

func (*Logger) SetLogFileLimits

func (logger *Logger) SetLogFileLimits(maxFileSize int, maxFileCount int)

SetLogFileLimits sets the log file limits.

func (*Logger) SetName

func (logger *Logger) SetName(name string)

SetName sets the log name.

func (*Logger) SetTarget

func (logger *Logger) SetTarget(target int) error

SetTarget sets the log target.

func (*Logger) SetTargetLogDirectory

func (logger *Logger) SetTargetLogDirectory(target int, logDirectory string) error

SetTargetLogDirectory sets the directory location where logs should be stored along with the target

func (*Logger) Warnf

func (logger *Logger) Warnf(format string, args ...interface{})

Warnf logs a formatted string at warninglevel

Jump to

Keyboard shortcuts

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