Documentation ¶
Overview ¶
Package log implements a simple library for message logging
Index ¶
- Constants
- func AddAlertFunc(f ChangeLevelAlertFunc) int64
- func CurrentLogLevelNamesOfAll() (list misc.StringMap)
- func CurrentLogLevelOfAll() (list map[string]Level)
- func DelAlertFunc(id int64)
- func Disable()
- func Enable()
- func FileName() string
- func FileNamePattern() string
- func GetLastLog() []string
- func GetLogLevelName(level Level) (short string, long string)
- func GetLogLevels() []string
- func MaxLen(ln int) int
- func Message(level Level, message string, params ...any)
- func MessageEx(shift int, level Level, replace *misc.Replace, message string, params ...any)
- func MessageWithSource(level Level, source string, message string, params ...any)
- func SecuredMessage(level Level, replace *misc.Replace, message string, params ...any)
- func SecuredMessageWithSource(level Level, replace *misc.Replace, source string, message string, ...)
- func SetConsoleWriter(writer io.Writer)
- func SetFile(directory string, suffix string, useLocalTime bool, bufSize int, ...)
- func SetLogLevels(defaultLevelName string, levels misc.StringMap, logFunc FuncNameMode) (err error)
- func SetTestWriter(stream *testing.T)
- func StdLogger(facility string, level string, message string, params ...any)
- func Writer() io.Writer
- type ChangeLevelAlertFunc
- type ConsoleWriter
- type Facility
- func (f *Facility) CurrentLogLevel() (level Level)
- func (f *Facility) CurrentLogLevelEx() (level Level, short string, long string)
- func (f *Facility) Message(level Level, message string, params ...any)
- func (f *Facility) MessageEx(shift int, level Level, replace *misc.Replace, message string, params ...any)
- func (f *Facility) MessageWithSource(level Level, source string, message string, params ...any)
- func (f *Facility) Name() (name string)
- func (f *Facility) SecuredMessage(level Level, replace *misc.Replace, message string, params ...any)
- func (f *Facility) SecuredMessageWithSource(level Level, replace *misc.Replace, source string, message string, ...)
- func (f *Facility) SetLogLevel(levelName string, funcNameMode FuncNameMode) (oldLevel Level, err error)
- type FuncNameMode
- type Level
- type ServiceLogger
- func (l *ServiceLogger) Error(v ...any) error
- func (l *ServiceLogger) Errorf(message string, a ...any) error
- func (l *ServiceLogger) Info(v ...any) error
- func (l *ServiceLogger) Infof(message string, a ...any) error
- func (l *ServiceLogger) Warning(v ...any) error
- func (l *ServiceLogger) Warningf(message string, a ...any) error
- type Testwriter
Constants ¶
const ( // FuncNameModeNone -- FuncNameModeNone = FuncNameMode("none") // FuncNameModeShort -- FuncNameModeShort = FuncNameMode("short") // FuncNameModeFull -- FuncNameModeFull = FuncNameMode("full") )
const StdFacilityName = ""
StdFacilityName --
Variables ¶
This section is empty.
Functions ¶
func CurrentLogLevelNamesOfAll ¶ added in v0.1.19
CurrentLogLevelNamesOfAll -- get all log levels
func CurrentLogLevelOfAll ¶ added in v0.1.19
CurrentLogLevelOfAll -- get all log levels
func GetLogLevelName ¶
GetLogLevelName -- get log level names
func MessageWithSource ¶
MessageWithSource -- add message to the log with source
func SecuredMessage ¶ added in v0.1.6
SecuredMessage -- add message to the log with securing
func SecuredMessageWithSource ¶ added in v0.1.6
func SecuredMessageWithSource(level Level, replace *misc.Replace, source string, message string, params ...any)
SecuredMessageWithSource -- add message to the log with source & securing
func SetFile ¶
func SetFile(directory string, suffix string, useLocalTime bool, bufSize int, flushPeriod time.Duration)
SetFile -- file for log
func SetLogLevels ¶ added in v0.1.20
func SetLogLevels(defaultLevelName string, levels misc.StringMap, logFunc FuncNameMode) (err error)
SetLogLevels -- set log level
Types ¶
type ChangeLevelAlertFunc ¶
ChangeLevelAlertFunc --
type Facility ¶ added in v0.1.19
type Facility struct {
// contains filtered or unexported fields
}
Facility --
func (*Facility) CurrentLogLevel ¶ added in v0.1.19
CurrentLogLevel -- get log level
func (*Facility) CurrentLogLevelEx ¶ added in v0.1.19
CurrentLogLevelEx -- get log level
func (*Facility) MessageEx ¶ added in v0.1.19
func (f *Facility) MessageEx(shift int, level Level, replace *misc.Replace, message string, params ...any)
MessageEx -- add message to the log with custom shift
func (*Facility) MessageWithSource ¶ added in v0.1.19
MessageWithSource -- add message to the log with source
func (*Facility) SecuredMessage ¶ added in v0.1.19
func (f *Facility) SecuredMessage(level Level, replace *misc.Replace, message string, params ...any)
SecuredMessage -- add message to the log with securing
func (*Facility) SecuredMessageWithSource ¶ added in v0.1.19
func (f *Facility) SecuredMessageWithSource(level Level, replace *misc.Replace, source string, message string, params ...any)
SecuredMessageWithSource -- add message to the log with source & securing
func (*Facility) SetLogLevel ¶ added in v0.1.20
func (f *Facility) SetLogLevel(levelName string, funcNameMode FuncNameMode) (oldLevel Level, err error)
SetLogLevel -- set log level
type Level ¶
type Level int
Level -- level of the logging
const ( // EMERG -- system is unusable EMERG Level = iota // ALERT -- action must be taken immediately ALERT // CRIT -- critical conditions CRIT // ERR -- error conditions ERR // WARNING -- warning conditions WARNING // NOTICE -- normal but significant condition NOTICE // INFO -- informational INFO // TIME -- execution time TIME // DEBUG -- debug-level messages DEBUG // TRACE1 -- trace 1 TRACE1 // TRACE2 -- trace 2 TRACE2 // TRACE3 -- trace 3 TRACE3 // TRACE4 -- trace 4 TRACE4 // UNKNOWN -- unknown level UNKNOWN )
func CurrentLogLevelEx ¶ added in v0.1.19
CurrentLogLevelEx --
func SetLogLevel ¶ added in v0.1.20
func SetLogLevel(levelName string, logFunc FuncNameMode) (oldLevel Level, err error)
SetLogLevel -- set log level
type ServiceLogger ¶
type ServiceLogger struct{}
ServiceLogger --
func (*ServiceLogger) Errorf ¶
func (l *ServiceLogger) Errorf(message string, a ...any) error
Errorf --
type Testwriter ¶
type Testwriter struct {
// contains filtered or unexported fields
}
Testwriter --