pleat

package module
v0.0.0-...-1f86c1b Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2020 License: MIT Imports: 13 Imported by: 0

README

pleat

Pleat is (yet another) Golang logger. The emphasis is on fields and easy day to day use while allowing full customization of the output.

Documentation

Index

Constants

View Source
const (
	FieldKeyMsg         = "msg"
	FieldKeyLevel       = "level"
	FieldKeyTime        = "time"
	FieldKeyLogrusError = "logrus_error"
	FieldKeyFunc        = "func"
	FieldKeyFile        = "file"
)

Default key names ...

Variables

AllLevels ...

View Source
var ErrorKey = "error"

ErrorKey ...

Functions

func AddHook

func AddHook(hook Hook)

AddHook ...

func Debug

func Debug(args ...interface{})

Debug ...

func DebugFn

func DebugFn(fn LogFunction)

DebugFn ...

func Debugf

func Debugf(format string, args ...interface{})

Debugf ...

func Debugln

func Debugln(args ...interface{})

Debugln ...

func DeferExitHandler

func DeferExitHandler(handler func())

DeferExitHandler ...

func Error

func Error(args ...interface{})

Error ...

func ErrorFn

func ErrorFn(fn LogFunction)

ErrorFn ...

func Errorf

func Errorf(format string, args ...interface{})

Errorf ...

func Errorln

func Errorln(args ...interface{})

Errorln ...

func Exit

func Exit(code int)

Exit ...

func Fatal

func Fatal(args ...interface{})

Fatal ...

func FatalFn

func FatalFn(fn LogFunction)

FatalFn ...

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf ...

func Fatalln

func Fatalln(args ...interface{})

Fatalln ...

func Info

func Info(args ...interface{})

Info ...

func InfoFn

func InfoFn(fn LogFunction)

InfoFn ...

func Infof

func Infof(format string, args ...interface{})

Infof ...

func Infoln

func Infoln(args ...interface{})

Infoln ...

func IsLevelEnabled

func IsLevelEnabled(level Level) bool

IsLevelEnabled ...

func Panic

func Panic(args ...interface{})

Panic ...

func PanicFn

func PanicFn(fn LogFunction)

PanicFn ...

func Panicf

func Panicf(format string, args ...interface{})

Panicf ...

func Panicln

func Panicln(args ...interface{})

Panicln ...

func Print

func Print(args ...interface{})

Print ...

func PrintFn

func PrintFn(fn LogFunction)

PrintFn ...

func Printf

func Printf(format string, args ...interface{})

Printf ...

func Println

func Println(args ...interface{})

Println ...

func RegisterExitHandler

func RegisterExitHandler(handler func())

RegisterExitHandler ...

func SetBufferPool

func SetBufferPool(bp BufferPool)

SetBufferPool ...

func SetFormatter

func SetFormatter(formatter Formatter)

SetFormatter ...

func SetLevel

func SetLevel(level Level)

SetLevel ...

func SetOutput

func SetOutput(out io.Writer)

SetOutput ...

func SetReportCaller

func SetReportCaller(include bool)

SetReportCaller ...

func Trace

func Trace(args ...interface{})

Trace ...

func TraceFn

func TraceFn(fn LogFunction)

TraceFn ...

func Tracef

func Tracef(format string, args ...interface{})

Tracef ...

func Traceln

func Traceln(args ...interface{})

Traceln ...

func Warn

func Warn(args ...interface{})

Warn ...

func WarnFn

func WarnFn(fn LogFunction)

WarnFn ...

func Warnf

func Warnf(format string, args ...interface{})

Warnf ...

func Warning

func Warning(args ...interface{})

Warning ...

func WarningFn

func WarningFn(fn LogFunction)

WarningFn ...

func Warningf

func Warningf(format string, args ...interface{})

Warningf ...

func Warningln

func Warningln(args ...interface{})

Warningln ...

func Warnln

func Warnln(args ...interface{})

Warnln ...

Types

type BufferPool

type BufferPool interface {
	Put(*bytes.Buffer)
	Get() *bytes.Buffer
}

type Entry

type Entry struct {
	Logger  *Logger
	Data    Fields
	Time    time.Time
	Level   Level
	Caller  *runtime.Frame
	Message string
	Buffer  *bytes.Buffer
	Context context.Context
}

Entry ...

func NewEntry

func NewEntry(logger *Logger) *Entry

NewEntry ...

func WithContext

func WithContext(ctx context.Context) *Entry

WithContext ...

func WithError

func WithError(err error) *Entry

WithError ...

func WithField

func WithField(key string, value interface{}) *Entry

WithField ...

func WithFields

func WithFields(fields Fields) *Entry

WithFields ...

func WithTime

func WithTime(t time.Time) *Entry

WithTime ...

func (*Entry) Bytes

func (entry *Entry) Bytes() ([]byte, error)

Bytes ...

func (*Entry) Debug

func (entry *Entry) Debug(args ...interface{})

func (*Entry) Debugf

func (entry *Entry) Debugf(format string, args ...interface{})

func (*Entry) Debugln

func (entry *Entry) Debugln(args ...interface{})

func (*Entry) Error

func (entry *Entry) Error(args ...interface{})

func (*Entry) Errorf

func (entry *Entry) Errorf(format string, args ...interface{})

func (*Entry) Errorln

func (entry *Entry) Errorln(args ...interface{})

func (*Entry) Fatal

func (entry *Entry) Fatal(args ...interface{})

func (*Entry) Fatalf

func (entry *Entry) Fatalf(format string, args ...interface{})

func (*Entry) Fatalln

func (entry *Entry) Fatalln(args ...interface{})

func (Entry) HasCaller

func (entry Entry) HasCaller() (has bool)

func (*Entry) Info

func (entry *Entry) Info(args ...interface{})

func (*Entry) Infof

func (entry *Entry) Infof(format string, args ...interface{})

func (*Entry) Infoln

func (entry *Entry) Infoln(args ...interface{})

func (*Entry) Log

func (entry *Entry) Log(level Level, args ...interface{})

Log ...

func (*Entry) Logf

func (entry *Entry) Logf(level Level, format string, args ...interface{})

func (*Entry) Logln

func (entry *Entry) Logln(level Level, args ...interface{})

func (*Entry) Panic

func (entry *Entry) Panic(args ...interface{})

func (*Entry) Panicf

func (entry *Entry) Panicf(format string, args ...interface{})

func (*Entry) Panicln

func (entry *Entry) Panicln(args ...interface{})

func (*Entry) Print

func (entry *Entry) Print(args ...interface{})

func (*Entry) Printf

func (entry *Entry) Printf(format string, args ...interface{})

func (*Entry) Println

func (entry *Entry) Println(args ...interface{})

func (*Entry) String

func (entry *Entry) String() (string, error)

String ...

func (*Entry) Trace

func (entry *Entry) Trace(args ...interface{})

func (*Entry) Tracef

func (entry *Entry) Tracef(format string, args ...interface{})

func (*Entry) Traceln

func (entry *Entry) Traceln(args ...interface{})

func (*Entry) Warn

func (entry *Entry) Warn(args ...interface{})

func (*Entry) Warnf

func (entry *Entry) Warnf(format string, args ...interface{})

func (*Entry) Warning

func (entry *Entry) Warning(args ...interface{})

func (*Entry) Warningf

func (entry *Entry) Warningf(format string, args ...interface{})

func (*Entry) Warningln

func (entry *Entry) Warningln(args ...interface{})

func (*Entry) Warnln

func (entry *Entry) Warnln(args ...interface{})

func (*Entry) WithContext

func (entry *Entry) WithContext(ctx context.Context) *Entry

WithContext ...

func (*Entry) WithError

func (entry *Entry) WithError(err error) *Entry

WithError ...

func (*Entry) WithField

func (entry *Entry) WithField(key string, value interface{}) *Entry

WithField ...

func (*Entry) WithFields

func (entry *Entry) WithFields(fields ...interface{}) *Entry

WithFields ...

func (*Entry) WithTime

func (entry *Entry) WithTime(t time.Time) *Entry

WithTime ...

func (*Entry) Writer

func (entry *Entry) Writer() *io.PipeWriter

Writer ...

func (*Entry) WriterLevel

func (entry *Entry) WriterLevel(level Level) *io.PipeWriter

WriterLevel ...

type FieldKey

type FieldKey string

type FieldLogger

type FieldLogger interface {
	WithField(key string, value interface{}) *Entry
	WithFields(fields ...interface{}) *Entry
	WithError(err error) *Entry

	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Printf(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
	Panicf(format string, args ...interface{})

	Debug(args ...interface{})
	Info(args ...interface{})
	Print(args ...interface{})
	Warn(args ...interface{})
	Warning(args ...interface{})
	Error(args ...interface{})
	Fatal(args ...interface{})
	Panic(args ...interface{})

	Debugln(args ...interface{})
	Infoln(args ...interface{})
	Println(args ...interface{})
	Warnln(args ...interface{})
	Warningln(args ...interface{})
	Errorln(args ...interface{})
	Fatalln(args ...interface{})
	Panicln(args ...interface{})
}

FieldLogger ...

type FieldMap

type FieldMap map[FieldKey]string

FieldMap ...

type Fields

type Fields map[string]interface{}

Fields ...

type Formatter

type Formatter interface {
	Format(*Entry) ([]byte, error)
}

Formatter ...

type Hook

type Hook interface {
	Levels() []Level
	Fire(*Entry) error
}

Hook ...

type JSONFormatter

type JSONFormatter struct {
	TimestampFormat   string
	DisableTimestamp  bool
	DisableHTMLEscape bool
	DataKey           string
	FieldMap          FieldMap
	CallerPrettyfier  func(*runtime.Frame) (function string, file string)
	PrettyPrint       bool
}

JSONFormatter ...

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(entry *Entry) ([]byte, error)

Format ...

type Level

type Level uint32

Level ...

const (
	PanicLevel Level = iota
	FatalLevel
	ErrorLevel
	WarnLevel
	InfoLevel
	DebugLevel
	TraceLevel
)

Levels ...

func GetLevel

func GetLevel() Level

GetLevel ...

func ParseLevel

func ParseLevel(lvl string) (Level, error)

ParseLeve ...

func (Level) MarshalText

func (level Level) MarshalText() ([]byte, error)

func (Level) String

func (level Level) String() string

String ...

func (*Level) UnmarshalText

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

UnmarshalText ...

type LevelHooks

type LevelHooks map[Level][]Hook

LevelHooks ...

func (LevelHooks) Add

func (hooks LevelHooks) Add(hook Hook)

Add ...

func (LevelHooks) Fire

func (hooks LevelHooks) Fire(level Level, entry *Entry) error

Fire ...

type LogFunction

type LogFunction func() []interface{}

LogFunction ...

type Logger

type Logger struct {
	Out          io.Writer
	ErrorOut     io.Writer
	Hooks        LevelHooks
	Formatter    Formatter
	ReportCaller bool
	Level        Level
	ExitFunc     exitFunc
	// contains filtered or unexported fields
}

func New

func New() *Logger

New ...

func StandardLogger

func StandardLogger() *Logger

func (*Logger) AddHook

func (logger *Logger) AddHook(hook Hook)

AddHook ...

func (*Logger) Debug

func (logger *Logger) Debug(args ...interface{})

func (*Logger) DebugFn

func (logger *Logger) DebugFn(fn LogFunction)

func (*Logger) Debugf

func (logger *Logger) Debugf(format string, args ...interface{})

func (*Logger) Debugln

func (logger *Logger) Debugln(args ...interface{})

func (*Logger) Error

func (logger *Logger) Error(args ...interface{})

func (*Logger) ErrorFn

func (logger *Logger) ErrorFn(fn LogFunction)

func (*Logger) Errorf

func (logger *Logger) Errorf(format string, args ...interface{})

func (*Logger) Errorln

func (logger *Logger) Errorln(args ...interface{})

func (*Logger) Exit

func (logger *Logger) Exit(code int)

func (*Logger) Fatal

func (logger *Logger) Fatal(args ...interface{})

func (*Logger) FatalFn

func (logger *Logger) FatalFn(fn LogFunction)

func (*Logger) Fatalf

func (logger *Logger) Fatalf(format string, args ...interface{})

func (*Logger) Fatalln

func (logger *Logger) Fatalln(args ...interface{})

func (*Logger) GetLevel

func (logger *Logger) GetLevel() Level

GetLevel ...

func (*Logger) Info

func (logger *Logger) Info(args ...interface{})

func (*Logger) InfoFn

func (logger *Logger) InfoFn(fn LogFunction)

func (*Logger) Infof

func (logger *Logger) Infof(format string, args ...interface{})

func (*Logger) Infoln

func (logger *Logger) Infoln(args ...interface{})

func (*Logger) IsLevelEnabled

func (logger *Logger) IsLevelEnabled(level Level) bool

IsLevelEnabled ...

func (*Logger) Log

func (logger *Logger) Log(level Level, args ...interface{})

func (*Logger) LogFn

func (logger *Logger) LogFn(level Level, fn LogFunction)

func (*Logger) Logf

func (logger *Logger) Logf(level Level, format string, args ...interface{})

func (*Logger) Logln

func (logger *Logger) Logln(level Level, args ...interface{})

func (*Logger) Panic

func (logger *Logger) Panic(args ...interface{})

func (*Logger) PanicFn

func (logger *Logger) PanicFn(fn LogFunction)

func (*Logger) Panicf

func (logger *Logger) Panicf(format string, args ...interface{})

func (*Logger) Panicln

func (logger *Logger) Panicln(args ...interface{})

func (*Logger) Print

func (logger *Logger) Print(args ...interface{})

func (*Logger) PrintFn

func (logger *Logger) PrintFn(fn LogFunction)

func (*Logger) Printf

func (logger *Logger) Printf(format string, args ...interface{})

func (*Logger) Println

func (logger *Logger) Println(args ...interface{})

func (*Logger) ReplaceHooks

func (logger *Logger) ReplaceHooks(hooks LevelHooks) LevelHooks

ReplaceHooks ...

func (*Logger) SetErrorOutput

func (logger *Logger) SetErrorOutput(output io.Writer)

SetErrorOutput ...

func (*Logger) SetFormatter

func (logger *Logger) SetFormatter(formatter Formatter)

SetFormatter ...

func (*Logger) SetLevel

func (logger *Logger) SetLevel(level Level)

SetLevel ...

func (*Logger) SetNoLock

func (logger *Logger) SetNoLock()

When file is opened with appending mode, it's safe to write concurrently to a file (within 4k message on Linux). In these cases user can choose to disable the lock.

func (*Logger) SetOutput

func (logger *Logger) SetOutput(output io.Writer)

SetOutput ...

func (*Logger) SetReportCaller

func (logger *Logger) SetReportCaller(reportCaller bool)

SetReportCaller ...

func (*Logger) Trace

func (logger *Logger) Trace(args ...interface{})

func (*Logger) TraceFn

func (logger *Logger) TraceFn(fn LogFunction)

func (*Logger) Tracef

func (logger *Logger) Tracef(format string, args ...interface{})

func (*Logger) Traceln

func (logger *Logger) Traceln(args ...interface{})

func (*Logger) Warn

func (logger *Logger) Warn(args ...interface{})

func (*Logger) WarnFn

func (logger *Logger) WarnFn(fn LogFunction)

func (*Logger) Warnf

func (logger *Logger) Warnf(format string, args ...interface{})

func (*Logger) Warning

func (logger *Logger) Warning(args ...interface{})

func (*Logger) WarningFn

func (logger *Logger) WarningFn(fn LogFunction)

func (*Logger) Warningf

func (logger *Logger) Warningf(format string, args ...interface{})

func (*Logger) Warningln

func (logger *Logger) Warningln(args ...interface{})

func (*Logger) Warnln

func (logger *Logger) Warnln(args ...interface{})

func (*Logger) WithContext

func (logger *Logger) WithContext(ctx context.Context) *Entry

WithContext ...

func (*Logger) WithError

func (logger *Logger) WithError(err error) *Entry

WithError ...

func (*Logger) WithField

func (logger *Logger) WithField(key string, value interface{}) *Entry

WithField ...

func (*Logger) WithFields

func (logger *Logger) WithFields(fields ...interface{}) *Entry

WithFields ...

func (*Logger) WithTime

func (logger *Logger) WithTime(t time.Time) *Entry

WithTime ...

func (*Logger) Writer

func (logger *Logger) Writer() *io.PipeWriter

Writer ...

func (*Logger) WriterLevel

func (logger *Logger) WriterLevel(level Level) *io.PipeWriter

WriterLevel ...

type MutexWrap

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

func (*MutexWrap) Disable

func (mw *MutexWrap) Disable()

func (*MutexWrap) Lock

func (mw *MutexWrap) Lock()

func (*MutexWrap) Unlock

func (mw *MutexWrap) Unlock()

type StdLogger

type StdLogger interface {
	Print(...interface{})
	Printf(string, ...interface{})
	Println(...interface{})

	Fatal(...interface{})
	Fatalf(string, ...interface{})
	Fatalln(...interface{})

	Panic(...interface{})
	Panicf(string, ...interface{})
	Panicln(...interface{})
}

StdLogger ...

type TextFormatter

type TextFormatter struct {
	ForceColors               bool
	DisableColors             bool
	ForceQuote                bool
	DisableQuote              bool
	EnvironmentOverrideColors bool
	DisableTimestamp          bool
	FullTimestamp             bool
	TimestampFormat           string
	DisableSorting            bool
	SortingFunc               func([]string)
	DisableLevelTruncation    bool
	PadLevelText              bool
	QuoteEmptyFields          bool
	FieldMap                  FieldMap
	CallerPrettyfier          func(*runtime.Frame) (function string, file string)
}

TextFormatter ...

func (*TextFormatter) Format

func (f *TextFormatter) Format(entry *Entry) ([]byte, error)

Format ...

Directories

Path Synopsis
hooks
test
The Test package is used for testing logrus.
The Test package is used for testing logrus.

Jump to

Keyboard shortcuts

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