package module
Version: v0.0.0-...-427edb4 Latest Latest

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

Go to latest
Published: Jan 12, 2023 License: GPL-3.0 Imports: 9 Imported by: 1



Golang logger with levels




This section is empty.


This section is empty.


func LevelAllow

func LevelAllow(level Level, l Logger) bool


type BaseLogger

type BaseLogger interface {
	Log(level Level, vs ...interface{})
	Logf(level Level, format string, vs ...interface{})

	Level() Level

Concept of a most simple interface:

type FormatText

type FormatText struct {
	HasLevel        bool
	HasDate         bool
	HasTime         bool
	HasMicroseconds bool
	ShieldSpecial   bool // { '\\', '"', '\n', '\r', '\t', '\f' }

func (FormatText) Formatter

func (f FormatText) Formatter() Formatter

type FormatWriter

type FormatWriter struct {
	Writer    io.Writer
	Formatter Formatter

func (*FormatWriter) WriteRecord

func (p *FormatWriter) WriteRecord(r *Record) error

type Formatter

type Formatter interface {
	Format(*Record) []byte

func FormatJSON

func FormatJSON() Formatter

type Level

type Level int
const (
	LevelOff      Level = iota // log: [ ]
	LevelCritical              // log: [ Critical ]
	LevelError                 // log: [ Critical, Error ]
	LevelWarning               // log: [ Critical, Error, Warning ]
	LevelInfo                  // log: [ Critical, Error, Warning, Info ]
	LevelDebug                 // log: [ Critical, Error, Warning, Info, Debug ]
	LevelTrace                 // log: [ Critical, Error, Warning, Info, Debug, Trace ]

func ParseLevel

func ParseLevel(s string) (Level, error)

func (Level) MarshalText

func (l Level) MarshalText() (text []byte, err error)

func (Level) String

func (l Level) String() string

func (*Level) UnmarshalText

func (l *Level) UnmarshalText(text []byte) error

type Logger

type Logger interface {

	Critical(vs ...interface{})
	Error(vs ...interface{})
	Warning(vs ...interface{})
	Info(vs ...interface{})
	Debug(vs ...interface{})
	Trace(vs ...interface{})

	Criticalf(format string, vs ...interface{})
	Errorf(format string, vs ...interface{})
	Warningf(format string, vs ...interface{})
	Infof(format string, vs ...interface{})
	Debugf(format string, vs ...interface{})
	Tracef(format string, vs ...interface{})

func MakeDummyLogger

func MakeDummyLogger() Logger

func MakeLogger

func MakeLogger(w io.Writer) Logger

func MakeLoggerStdout

func MakeLoggerStdout() Logger

func NewLoggerRW

func NewLoggerRW(rw RecordWriter) Logger

type Record

type Record struct {
	Time    time.Time
	Level   Level
	Message string

type RecordWriter

type RecordWriter interface {
	WriteRecord(*Record) error

func DummyRecordWriter

func DummyRecordWriter() RecordWriter

func FilterRecordWriter

func FilterRecordWriter(filter func(*Record) bool, rw RecordWriter) RecordWriter

func FuncRecordWriter

func FuncRecordWriter(f func(*Record) error) RecordWriter

func MultiRecordWriter

func MultiRecordWriter(rws ...RecordWriter) RecordWriter

func NewStreamRW

func NewStreamRW(w io.Writer, f Formatter) RecordWriter


Path Synopsis

Jump to

Keyboard shortcuts

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