gologger

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2024 License: MIT Imports: 5 Imported by: 2

README

gologger

a logger used in go

Documentation

Index

Constants

View Source
const (
	ErrorTemplate = "\033[1;31m%s\033[0m"
	WarnTemplate  = "\033[1;33m%s\033[0m"
	InfoTemplate  = "\033[1;32m%s\033[0m"
	DebugTemplate = "\033[1;34m%s\033[0m"
	TraceTemplate = "\033[1;35m%s\033[0m"
)
View Source
const (
	NoLog = iota
	Error
	Warn
	Info
	Debug
	Trace
)

Variables

This section is empty.

Functions

func Configure

func Configure(config LoggersConfig)

func RegistAppender

func RegistAppender(typeName string, appenderCreatCb func(LogAppenderConfig) *LoggerAppender)

Types

type ConsoleAppender

type ConsoleAppender struct {
}

func (*ConsoleAppender) Append

func (c *ConsoleAppender) Append(logEvent LogEvent)

func (*ConsoleAppender) Close

func (c *ConsoleAppender) Close()

Close implements LoggerAppender.

func (*ConsoleAppender) GetName

func (c *ConsoleAppender) GetName() string

type FileAppender

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

func (*FileAppender) Append

func (f *FileAppender) Append(logEvent LogEvent)

func (*FileAppender) Close

func (f *FileAppender) Close()

Close implements LoggerAppender.

func (*FileAppender) GetName

func (f *FileAppender) GetName() string

type LogAppenderConfig

type LogAppenderConfig struct {
	Type    string                 `json:"type"`
	Options map[string]interface{} `json:"options"`
}

type LogConfig

type LogConfig struct {
	Level     string   `json:"level"`
	Appenders []string `json:"appenders"`
}

type LogEvent

type LogEvent struct {
	Category string
	Ts       time.Time
	Level    int
	Data     []interface{}
}

type Logger

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

func GetLogger

func GetLogger(name string) *Logger

func (*Logger) Debug

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

func (*Logger) Error

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

func (*Logger) Info

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

func (*Logger) Trace

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

func (*Logger) Warn

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

type LoggerAppender

type LoggerAppender interface {
	GetName() string
	Append(logEvent LogEvent)
	Close()
}

type LoggersConfig

type LoggersConfig struct {
	Appenders  map[string]LogAppenderConfig `json:"appenders"`
	Categories map[string]LogConfig         `json:"categories"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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