log

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 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

This section is empty.

Variables

This section is empty.

Functions

func AddAlertFunc

func AddAlertFunc(f ChangeLevelAlertFunc) int64

AddAlertFunc --

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 Message

func Message(level Level, message string, params ...interface{})

Message -- add message to the log

func MessageEx

func MessageEx(shift int, level Level, message string, params ...interface{})

MessageEx -- add message to the log with custom shift

func MessageWithSource

func MessageWithSource(level Level, source string, message string, params ...interface{})

MessageWithSource -- add message to the log with source

func SetConsoleWriter

func SetConsoleWriter(writer io.Writer)

SetConsoleWriter --

func SetFile

func SetFile(directory string, suffix string, useLocalTime bool, bufSize int, flushPeriod int)

SetFile -- file for log

func SetTestWriter

func SetTestWriter(stream *testing.T)

SetTestWriter --

func StdLogger

func StdLogger(level string, message string, params ...interface{})

StdLogger --

Types

type ChangeLevelAlertFunc

type ChangeLevelAlertFunc func(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 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
	// 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 GetCurrentLogLevel

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

GetCurrentLogLevel -- get log level

func SetCurrentLogLevel

func SetCurrentLogLevel(levelName string, logFunc string) (Level, error)

SetCurrentLogLevel -- 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 ...interface{}) error

Error --

func (*ServiceLogger) Errorf

func (l *ServiceLogger) Errorf(message string, a ...interface{}) error

Errorf --

func (*ServiceLogger) Info

func (l *ServiceLogger) Info(v ...interface{}) error

Info --

func (*ServiceLogger) Infof

func (l *ServiceLogger) Infof(message string, a ...interface{}) error

Infof --

func (*ServiceLogger) Warning

func (l *ServiceLogger) Warning(v ...interface{}) error

Warning --

func (*ServiceLogger) Warningf

func (l *ServiceLogger) Warningf(message string, a ...interface{}) 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