logs

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

Default is the default global logger.

View Source
var DefaultDispatcher sparalog.Dispatcher

DefaultDispatcher is the default global dispatcher.

View Source
var DefaultStdoutWriter sparalog.Writer

DefaultStdoutWriter is the default global writer to stdout.

Functions

func AddLevelWriter

func 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 AddLevelsWriter

func 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 AddWriter

func AddWriter(w sparalog.Writer, id sparalog.WriterID)

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

func Debug

func Debug(args ...interface{})

Debug sends to Default logger debug stream using the same fmt.Print() interface.

func Debugf

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

Debugf sends to Default logger debug stream using the same fmt.Printf() interface.

func Done

func Done()

Done manages (current routine) panics and closes all the loggers, waiting gently for the async writers. It should be called at main exit.

func EnableStacktrace

func EnableStacktrace(level sparalog.Level, state bool)

EnableStacktrace enable stacktrace for a specific level.

func Error

func Error(args ...interface{})

Error sends to Default logger error stream using the same fmt.Print() interface.

func Errorf

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

Errorf sends to Default logger error stream using the same fmt.Printf() interface.

func Fatal

func Fatal(args ...interface{})

Fatal sends to Default logger fatal stream using the same fmt.Print() interface.

func Fatalf

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

Fatalf sends to Default logger fatal stream using the same fmt.Printf() interface.

func Info

func Info(args ...interface{})

Info sends to Default logger info stream using the same fmt.Print() interface.

func Infof

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

Infof sends to Default logger info stream using the same fmt.Printf() interface.

func Mute

func Mute(level sparalog.Level, state bool)

Mute mute/unmute a specific level.

func NewAliasLogger

func NewAliasLogger() sparalog.Logger

NewAliasLogger allocate a logger that uses logs.Default writers.

func NewCallbackAsyncWriter

func NewCallbackAsyncWriter(callback writers.CallbackWriterCallback) sparalog.Writer

NewCallbackAsyncWriter returns a new callbackAsyncWriter.

func NewCallbackWriter

func NewCallbackWriter(callback writers.CallbackWriterCallback) sparalog.Writer

NewCallbackWriter returns a new callbackWriter.

func NewError

func NewError(err error) sparalog.Item

NewError generate a new log item wrapping an error.

func NewErrorf

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

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

func NewFileWriter

func NewFileWriter(filename string) (sparalog.Writer, error)

NewFileWriter returns a new fileWriter.

func NewItem

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

NewItem generate a new log item for the default logger.

func NewItemf

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

NewItemf generate a new log item for the default logger.

func NewLogger

func NewLogger() *logger.Logger

NewLogger allocates, registers and returns a new Logger.

func NewSentryWriter

func NewSentryWriter() sparalog.Writer

NewSentryWriter returns a new sentryWriter.

func NewStdoutWriter

func NewStdoutWriter() sparalog.Writer

NewStdoutWriter returns a new stdoutWriter.

func NewSyslogWriter

func NewSyslogWriter(tag string) sparalog.Writer

NewSyslogWriter returns a new syslogWriter.

func NewTCPWriter

func NewTCPWriter(address string, port int, debug bool, cb writers.StateChangeCallback) (sparalog.Writer, error)

NewTCPWriter return a new tcpWriter.

func NewTelegramWriter

func NewTelegramWriter(botAPIKey string, channelID int) sparalog.Writer

NewTelegramWriter returns a new telegramWriter.

func Open

func Open()

Open start the logger an all the writers. It should be called after writers initialization.

func Print

func Print(args ...interface{})

Print sends to Default logger info stream using the same fmt.Print() interface.

func Printf

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

Printf sends to Default logger info stream using the same fmt.Printf() interface.

func RemoveWriter

func RemoveWriter(level sparalog.Level, id sparalog.WriterID)

RemoveWriter delete a specific writer from level.

func ResetLevelWriters

func ResetLevelWriters(level sparalog.Level, defaultW sparalog.Writer)

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

func ResetLevelsWriters

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

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

func ResetWriters

func ResetWriters(defaultW sparalog.Writer)

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

func SetContextData

func SetContextData(key string, value interface{})

SetContextData sets a context data payload.

func SetContextPrefix

func 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 SetContextTag

func SetContextTag(name, value string)

SetContextTag sets a context tag.

func StartPanicWatcher

func StartPanicWatcher()

StartPanicWatcher starts a supervisor that monitors panics in all goroutines. Since the supervision is made starting a parent + child processes: - Call the function after all writers initialization, or at least after fatal level initialization; - This function should not to be called in debugging sessions.

func Trace

func Trace(args ...interface{})

Trace sends to Default logger trace stream using the same fmt.Print() interface.

func Tracef

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

Tracef sends to Default logger trace stream using the same fmt.Printf() interface.

func Warn

func Warn(args ...interface{})

Warn sends to Default logger warning stream using the same fmt.Print() interface.

func Warnf

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

Warnf sends to Default logger warning stream using the same fmt.Printf() interface.

Types

This section is empty.

Jump to

Keyboard shortcuts

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