logger

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAlias

func NewAlias(logger sparalog.Logger, dispatcher sparalog.Dispatcher) sparalog.Logger

NewAlias allocate a logger using another logger context and another dispatcher.

Types

type Dispatcher

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

Dispatcher implements sparalog.Dispatcher

func NewDispatcher

func NewDispatcher(defaultWriter sparalog.Writer) *Dispatcher

NewDispatcher allocate and initialize a new dispatcher.

func (*Dispatcher) AddLevelWriter

func (d *Dispatcher) AddLevelWriter(level sparalog.Level, w sparalog.Writer, id sparalog.WriterID)

AddLevelWriter add a writer to a level. id is optional, but useful for RemoveWriter().

func (*Dispatcher) AddLevelsWriter

func (d *Dispatcher) AddLevelsWriter(levels []sparalog.Level, w sparalog.Writer, id sparalog.WriterID)

AddLevelsWriter add a writer to several levels. id is optional, but useful for RemoveWriter().

func (*Dispatcher) AddWriter

func (d *Dispatcher) AddWriter(w sparalog.Writer, id sparalog.WriterID)

AddWriter add a writer to all levels. id is optional, but useful for RemoveWriter().

func (*Dispatcher) Dispatch

func (d *Dispatcher) Dispatch(item sparalog.Item)

Dispatch sends an Item to the level writers.

func (*Dispatcher) EnableStacktrace

func (d *Dispatcher) EnableStacktrace(level sparalog.Level, state bool)

EnableStacktrace enable stacktrace for a specific level.

func (*Dispatcher) LevelState

func (d *Dispatcher) LevelState(level sparalog.Level) sparalog.LevelState

LevelState return a level status.

func (*Dispatcher) Mute

func (d *Dispatcher) Mute(level sparalog.Level, state bool)

Mute mute/unmute a specific level.

func (*Dispatcher) RemoveWriter

func (d *Dispatcher) RemoveWriter(level sparalog.Level, id sparalog.WriterID)

RemoveWriter delete a specific writer from level.

func (*Dispatcher) ResetLevelWriters

func (d *Dispatcher) ResetLevelWriters(level sparalog.Level, defaultW sparalog.Writer)

ResetLevelWriters remove all level's writers and reset to an optional default writer.

func (*Dispatcher) ResetLevelsWriters

func (d *Dispatcher) ResetLevelsWriters(levels []sparalog.Level, defaultW sparalog.Writer)

ResetLevelsWriters remove specific levels writers and reset to an optional default writer.

func (*Dispatcher) ResetWriters

func (d *Dispatcher) ResetWriters(defaultW sparalog.Writer)

ResetWriters reset the writers for all the levels to an optional default writer.

func (*Dispatcher) Start

func (d *Dispatcher) Start() error

Start starts all the writers.

func (*Dispatcher) Stop

func (d *Dispatcher) Stop()

Stop terminate all the writers.

type Logger

type Logger struct {
	Dispatcher sparalog.Dispatcher
	// contains filtered or unexported fields
}

Logger implements Logger inferface.

func New

func New(defaultWriter sparalog.Writer) *Logger

New allocate a new logger.

func (*Logger) CloneContext

func (l *Logger) CloneContext() sparalog.Context

CloneContext returns a clone of the current context.

func (*Logger) Close

func (l *Logger) Close()

Close terminates loggers and all the writers.

func (*Logger) Debug

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

Debug logs to debug stream using the same fmt.Print() interface.

func (*Logger) Debugf

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

Debugf logs to debug stream using the same fmt.Printf() interface.

func (*Logger) Error

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

Error logs to error stream using the same fmt.Print() interface.

func (*Logger) Errorf

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

Errorf logs to error stream using the same fmt.Printf() interface.

func (*Logger) Fatal

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

Fatal logs to fatal stream using the same fmt.Print() interface.

func (*Logger) Fatalf

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

Fatalf logs to fatal stream using the same fmt.Printf() interface.

func (*Logger) Info

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

Info logs to info stream using the same fmt.Print() interface.

func (*Logger) Infof

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

Infof logs to info stream using the same fmt.Printf() interface.

func (*Logger) Log

func (l *Logger) Log(level sparalog.Level, stackTrace string, args ...interface{})

Log to level stream - entry point for all the helpers; thread safe.

func (*Logger) LogItem

func (l *Logger) LogItem(item sparalog.Item)

LogItem logs an item to level stream - thread safe.

func (*Logger) Logf

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

Logf logs to level stream using format - entry point for all the helpers; thread safe.

func (*Logger) NewError

func (l *Logger) NewError(err error) sparalog.Item

NewError generate a new log item wrapping an error.

func (*Logger) NewErrorItem

func (l *Logger) NewErrorItem(line string) sparalog.Item

NewErrorItem generate a new log error item with stack trace, excluding the caller. Entry point for all the NewError* helpers.

func (*Logger) NewErrorf

func (l *Logger) NewErrorf(format string, a ...interface{}) sparalog.Item

NewErrorf generate a new log item wrapping an error, as Errorf().

func (*Logger) NewItem

func (l *Logger) NewItem(level sparalog.Level, args ...string) sparalog.Item

NewItem generate a new log item.

func (*Logger) NewItemf

func (l *Logger) NewItemf(level sparalog.Level, format string, args ...string) sparalog.Item

NewItemf generate a new log item.

func (*Logger) Open

func (l *Logger) Open() error

Open start loggers and all the writers.

func (*Logger) Print

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

Print logs to info stream using the same fmt.Print() interface.

func (*Logger) Printf

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

Printf logs to info stream using the same fmt.Printf() interface.

func (*Logger) SetContextData

func (l *Logger) SetContextData(key string, value interface{})

SetContextData sets a context data payload.

func (*Logger) SetContextPrefix

func (l *Logger) SetContextPrefix(format string, tags []string)

SetContextPrefix sets the context prefix. Tags is the list of the tags names that will be rendered according to format.

func (*Logger) SetContextTag

func (l *Logger) SetContextTag(name, value string)

SetContextTag sets a context tag.

func (*Logger) Trace

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

Trace logs to trace stream using the same fmt.Print() interface.

func (*Logger) Tracef

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

Tracef logs to trace stream using the same fmt.Printf() interface.

func (*Logger) Warn

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

Warn logs to warning stream using the same fmt.Print() interface.

func (*Logger) Warnf

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

Warnf logs to warning stream using the same fmt.Printf() interface.

Jump to

Keyboard shortcuts

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