log

package module
v0.1.37 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2023 License: MIT Imports: 12 Imported by: 27

README

Package log implements a simple library for message logging

Documentation

Overview

Package log implements a simple library for message logging

Index

Constants

View Source
const (
	// FuncNameModeNone --
	FuncNameModeNone = FuncNameMode("none")
	// FuncNameModeShort --
	FuncNameModeShort = FuncNameMode("short")
	// FuncNameModeFull --
	FuncNameModeFull = FuncNameMode("full")
)
View Source
const StdFacilityName = ""

StdFacilityName --

Variables

This section is empty.

Functions

func AddAlertFunc

func AddAlertFunc(f ChangeLevelAlertFunc) int64

AddAlertFunc --

func CurrentLogLevelNamesOfAll added in v0.1.19

func CurrentLogLevelNamesOfAll() (list misc.StringMap)

CurrentLogLevelNamesOfAll -- get all log levels

func CurrentLogLevelOfAll added in v0.1.19

func CurrentLogLevelOfAll() (list map[string]Level)

CurrentLogLevelOfAll -- get all log levels

func DelAlertFunc

func DelAlertFunc(id int64)

DelAlertFunc --

func Disable

func Disable()

Disable --

func Enable

func Enable()

Enable --

func FileName

func FileName() string

FileName --

func FileNamePattern

func FileNamePattern() string

FileNamePattern --

func GetLastLog

func GetLastLog() []string

GetLastLog --

func GetLogLevelName

func GetLogLevelName(level Level) (short string, long string)

GetLogLevelName -- get log level names

func GetLogLevels

func GetLogLevels() []string

GetLogLevels -- get log level list

func MaxLen added in v0.1.3

func MaxLen(ln int) int

MaxLen --

func Message

func Message(level Level, message string, params ...any)

Message -- add message to the log

func MessageEx

func MessageEx(shift int, level Level, replace *misc.Replace, message string, params ...any)

MessageEx -- add message to the log with custom shift

func MessageWithSource

func MessageWithSource(level Level, source string, message string, params ...any)

MessageWithSource -- add message to the log with source

func SecuredMessage added in v0.1.6

func SecuredMessage(level Level, replace *misc.Replace, message string, params ...any)

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 SetConsoleWriter

func SetConsoleWriter(writer io.Writer)

SetConsoleWriter --

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

func SetTestWriter

func SetTestWriter(stream *testing.T)

SetTestWriter --

func StdLogger

func StdLogger(facility string, level string, message string, params ...any)

StdLogger --

func Writer added in v0.1.27

func Writer() io.Writer

Writer --

Types

type ChangeLevelAlertFunc

type ChangeLevelAlertFunc func(facility string, old Level, new Level)

ChangeLevelAlertFunc --

type ConsoleWriter

type ConsoleWriter struct{}

ConsoleWriter --

func (*ConsoleWriter) Write

func (l *ConsoleWriter) Write(p []byte) (n int, err error)

type Facility added in v0.1.19

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

Facility --

func GetFacility added in v0.1.19

func GetFacility(name string) *Facility

GetFacility --

func NewFacility added in v0.1.19

func NewFacility(name string) *Facility

NewFacility --

func StdFacility added in v0.1.23

func StdFacility() *Facility

StdFacility --

func (*Facility) CurrentLogLevel added in v0.1.19

func (f *Facility) CurrentLogLevel() (level Level)

CurrentLogLevel -- get log level

func (*Facility) CurrentLogLevelEx added in v0.1.19

func (f *Facility) CurrentLogLevelEx() (level Level, short string, long string)

CurrentLogLevelEx -- get log level

func (*Facility) Message added in v0.1.19

func (f *Facility) Message(level Level, message string, params ...any)

Message -- add message to the log

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

func (f *Facility) MessageWithSource(level Level, source string, message string, params ...any)

MessageWithSource -- add message to the log with source

func (*Facility) Name added in v0.1.21

func (f *Facility) Name() (name string)

Name -- get facility name

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 FuncNameMode added in v0.1.19

type FuncNameMode string

FuncNameMode --

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 CurrentLogLevel added in v0.1.19

func CurrentLogLevel() (level Level)

CurrentLogLevel --

func CurrentLogLevelEx added in v0.1.19

func CurrentLogLevelEx() (level Level, short string, long string)

CurrentLogLevelEx --

func SetLogLevel added in v0.1.20

func SetLogLevel(levelName string, logFunc FuncNameMode) (oldLevel Level, err error)

SetLogLevel -- set log level

func Str2Level

func Str2Level(levelName string) (level Level, ok bool)

Str2Level --

type ServiceLogger

type ServiceLogger struct{}

ServiceLogger --

func (*ServiceLogger) Error

func (l *ServiceLogger) Error(v ...any) error

Error --

func (*ServiceLogger) Errorf

func (l *ServiceLogger) Errorf(message string, a ...any) error

Errorf --

func (*ServiceLogger) Info

func (l *ServiceLogger) Info(v ...any) error

Info --

func (*ServiceLogger) Infof

func (l *ServiceLogger) Infof(message string, a ...any) error

Infof --

func (*ServiceLogger) Warning

func (l *ServiceLogger) Warning(v ...any) error

Warning --

func (*ServiceLogger) Warningf

func (l *ServiceLogger) Warningf(message string, a ...any) error

Warningf --

type Testwriter

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

Testwriter --

func (*Testwriter) Write

func (l *Testwriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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