gologger

package
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ldate         = 1 << iota // the date in the local time zone: 2009/01/23
	Ltime                     // the time in the local time zone: 01:23:23
	Lmicroseconds             // microsecond resolution: 01:23:23.123123.  assumes Ltime.
	Llongfile                 // full file name and line number: /a/b/c/d.go:23
	Lshortfile                // final file name element and line number: d.go:23. overrides Llongfile
	Lutc                      // if Ldate or Ltime is set, use UTC rather than the local time zone

	LNoStackTrace // No Run runtime.Caller()  for getting Stack Trace info

	LstdFlags = Ldate | Ltime // initial values for the standard Logger
)

These flags define which text to prefix to each log entry generated by the LoggerI. Bits are or'ed together to control what's printed. For example, flags Ldate | Ltime (or LstdFlags) produce,

2009/01/23 01:23:23 message

while flags Ldate | Ltime | Lmicroseconds | Llongfile produce,

2009/01/23 01:23:23.123123 /a/b/c/d.go:23: message

Variables

LoggerColorSchemeDetached - Привязка обозначений цветовой схемы colormap к уровням логирования

Functions

This section is empty.

Types

type ColorFlag

type ColorFlag int

ColorFlag - type of color flag

const (
	NoColor ColorFlag = iota
	Color
)

Const for Color or NoColor Mode

type DestinationFlag

type DestinationFlag int

DestinationFlag - type of destination flag

const (
	OffAll DestinationFlag = iota
	OnNoColor
	OnColor
	OnAll
)

Const for destination

type Destinations

type Destinations map[LogLvl][]io.Writer

Destinations - map of log_lvl/color destinations

func GetDefaultDestinations

func GetDefaultDestinations() (defaultDest Destinations)

GetDefaultDestinations - get default destination

type LogHandler

type LogHandler func(*Logger, ...interface{}) // Func which execute in specific Log method (Info, Debug and etc.)

LogHandler - function of handlers

type LogLvl

type LogLvl int

LogLvl - type of log lvl

const (
	Info LogLvl = iota
	Debug
	Warning
	Error
	Fatal
	Test
	Print
	P
	Other
	Db
	Redis
	Memchd
	DbOk
	DbFail
	RedisOk
	RedisFail
	MemchdOk
	MemchdFail
)

const for logger lvl

type LogMap

type LogMap map[LogLvl][]LogHandler

LogMap - map of LogHandlers

type Logger

type Logger struct {
	Destinations // TwoD-slice of io.Writers
	LogMap       // Map []LogHandlers
	// contains filtered or unexported fields
}

Logger -Main struct of Logger

func (*Logger) Close

func (l *Logger) Close()

Close - close inner chan for transfer msg into Logger

func (*Logger) Debug

func (l *Logger) Debug(msg ...interface{})

Debug - log with Debug lvl

func (*Logger) DisableDestinationLvl

func (l *Logger) DisableDestinationLvl(lvl LogLvl)

DisableDestinationLvl - disable destination lvl

func (*Logger) DisableDestinationLvlColor

func (l *Logger) DisableDestinationLvlColor(lvl LogLvl, color ColorFlag)

DisableDestinationLvlColor - disable destination lvl color

func (*Logger) EnableDestinationLvl

func (l *Logger) EnableDestinationLvl(lvl LogLvl)

EnableDestinationLvl - enable destination lvl

func (*Logger) EnableDestinationLvlColor

func (l *Logger) EnableDestinationLvlColor(lvl LogLvl, color ColorFlag)

EnableDestinationLvlColor - enable destination lvl color

func (*Logger) Error

func (l *Logger) Error(msg ...interface{})

Error - log with Error lvl

func (*Logger) Fatal

func (l *Logger) Fatal(msg ...interface{})

Fatal - log with Fatal lvl

func (*Logger) GetDestinationLvl

func (l *Logger) GetDestinationLvl(lvl LogLvl) []io.Writer

GetDestinationLvl - get destination by lvl

func (*Logger) GetDestinationLvlColor

func (l *Logger) GetDestinationLvlColor(lvl LogLvl, color ColorFlag) io.Writer

GetDestinationLvlColor - get destination by lvl & color

func (*Logger) Info

func (l *Logger) Info(msg ...interface{})

Info - log with Info lvl

func (*Logger) Log

func (l *Logger) Log(lvl LogLvl, msg ...interface{})

Log - func log with custom LogLvl

func (*Logger) LogC

func (l *Logger) LogC(lvl LogLvl, cf ColorFlag, msg ...interface{})

LogC - color func log with custom LogLvl

func (*Logger) Other

func (l *Logger) Other(msg ...interface{})

Other - log with Other lvl

func (*Logger) P

func (l *Logger) P()

P - log with P lvl

func (*Logger) Print

func (l *Logger) Print(msg ...interface{})

Print - log with Print lvl

func (*Logger) SetAndEnableDestinationLvl

func (l *Logger) SetAndEnableDestinationLvl(lvl LogLvl, d []io.Writer)

SetAndEnableDestinationLvl - set and enable destination lvl

func (*Logger) SetAndEnableDestinationLvlColor

func (l *Logger) SetAndEnableDestinationLvlColor(lvl LogLvl, color ColorFlag, d io.Writer)

SetAndEnableDestinationLvlColor - set and enable destination lvl color

func (*Logger) SetColorScheme

func (l *Logger) SetColorScheme(cs colormap.CSM)

SetColorScheme - set color scheme

func (*Logger) SetColorThemeName

func (l *Logger) SetColorThemeName(name string)

SetColorThemeName - set color theme by name

func (*Logger) SetDefaultDestinations

func (l *Logger) SetDefaultDestinations(defaultWriter io.Writer, flag DestinationFlag)

SetDefaultDestinations - set default destination

func (*Logger) SetDestinationLvl

func (l *Logger) SetDestinationLvl(lvl LogLvl, sWriters []io.Writer)

SetDestinationLvl - set destination to lvl

func (*Logger) SetDestinationLvlColor

func (l *Logger) SetDestinationLvlColor(lvl LogLvl, color ColorFlag, writer io.Writer)

SetDestinationLvlColor - set destination to lvl & color

func (*Logger) SetNewDestinations

func (l *Logger) SetNewDestinations(destinations Destinations)

SetNewDestinations - set new destination

func (*Logger) Test

func (l *Logger) Test(msg ...interface{})

Test - log with Test lvl

func (*Logger) Warning

func (l *Logger) Warning(msg ...interface{})

Warning - log with Warning lvl

type LoggerBean

type LoggerBean struct {
	Output                               string
	DestFlag, N, CallDepth, SettingFlags int
	Delimiter, ThemeName                 string
}

LoggerBean - Bean описывающий настройки логера

type LoggerController

type LoggerController interface {
	SetColorScheme(colormap.CSM)
	SetColorThemeName(string)

	SetDefaultDestinations(io.Writer, DestinationFlag)
	SetNewDestinations(Destinations)

	SetDestinationLvl(LogLvl, []io.Writer)
	GetDestinationLvl(LogLvl) []io.Writer
	SetDestinationLvlColor(LogLvl, ColorFlag, io.Writer)
	GetDestinationLvlColor(LogLvl, ColorFlag) io.Writer

	DisableDestinationLvl(LogLvl)
	DisableDestinationLvlColor(LogLvl, ColorFlag)

	EnableDestinationLvl(LogLvl)
	EnableDestinationLvlColor(LogLvl, ColorFlag)

	SetAndEnableDestinationLvl(LogLvl, []io.Writer)
	SetAndEnableDestinationLvlColor(LogLvl, ColorFlag, io.Writer)
}

LoggerController - sub interface for LoggerI (control action) Interface LoggerI Controller describes base control settings of Logger: color map and I/O mechanism) ALL METHOD UNDER MUTEX!

type LoggerI

type LoggerI interface {
	Log(lvl LogLvl, msg ...interface{})
	LogC(lvl LogLvl, cf ColorFlag, msg ...interface{})

	Info(...interface{})
	Debug(...interface{})
	Warning(...interface{})
	Error(...interface{})
	Fatal(...interface{})

	Test(...interface{})
	Print(...interface{})
	P()
	Other(...interface{})

	LoggerController

	Close()
}

LoggerI - Main interface of GoLogger

func NewLogger

func NewLogger(defaultOutput io.Writer, destFlag DestinationFlag, n, callDepth, settingFlags int, delimiter string, csm colormap.CSM) LoggerI

NewLogger - Constructor LoggerI

Jump to

Keyboard shortcuts

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