Documentation ¶
Index ¶
- Constants
- Variables
- type LogFileWriter
- type Logger
- func (el *Logger) ApplyOptions(opts ...Option) error
- func (el *Logger) ChangePrinterHookWriter(wr io.Writer) error
- func (el *Logger) Debug(message string, extra ...interface{})
- func (el *Logger) Error(message string, extra ...interface{})
- func (el *Logger) File() io.Writer
- func (el *Logger) Headline(message string, timestamp string, delimiter string) string
- func (el *Logger) Info(message string, extra ...interface{})
- func (el *Logger) LogIfError(err error)
- func (el *Logger) Panic(message string, extra ...interface{})
- func (el *Logger) SetLevel(level string)
- func (el *Logger) SetOutput(out io.Writer)
- func (el *Logger) StackTraceDepth() int
- func (el *Logger) Warn(message string, extra ...interface{})
- type Option
Constants ¶
const ( LogDebug = "DEBUG" LogInfo = "INFO" LogWarning = "WARNING" LogError = "ERROR" LogPanic = "PANIC" )
These constants are the string representation of the package logging levels.
Variables ¶
var ErrNilFile = errors.New("can not use nil file")
ErrNilFile signals that the provided file is nil
Functions ¶
This section is empty.
Types ¶
type LogFileWriter ¶
type LogFileWriter struct {
// contains filtered or unexported fields
}
LogFileWriter is a custom io.Writer implementation suited for our application. While a writer is not provided, it will write to standard output and record all entries in a slice. After the writer will be provided, the buffer slice will be set to nil and the provided writer will be called from this point on.
func (*LogFileWriter) SetWriter ¶
func (lfw *LogFileWriter) SetWriter(writer io.Writer)
SetWriter will set the writer
func (*LogFileWriter) Write ¶
func (lfw *LogFileWriter) Write(p []byte) (n int, err error)
Write handles the output of this writer
func (*LogFileWriter) Writer ¶
func (lfw *LogFileWriter) Writer() io.Writer
Writer will return the current writer
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger represents the application logger.
func DefaultLogger ¶
func DefaultLogger() *Logger
DefaultLogger is a shorthand for instantiating a new logger with default settings. If it fails to open the default log file it will return a logger with os.Stdout output.
func NewElrondLogger ¶
NewElrondLogger will setup the defaults of the application logger. If the requested log file is writable it will setup a MultiWriter on both the file
and the standard output. Also sets up the level and the format for the logger.
func (*Logger) ApplyOptions ¶
ApplyOptions can set up different configurable options of a Logger instance
func (*Logger) ChangePrinterHookWriter ¶ added in v1.0.12
ChangePrinterHookWriter will change io writer of the hook
func (*Logger) Headline ¶
Headline will build a headline message given a delimiter string
timestamp parameter will be printed before the repeating delimiter
func (*Logger) LogIfError ¶
LogIfError will log if the provided error different than nil
func (*Logger) SetOutput ¶
SetOutput enables the possibility to change the output of the logger on demand.
func (*Logger) StackTraceDepth ¶
StackTraceDepth returns the current Logger stackTraceDepth
type Option ¶
Option represents a functional configuration parameter that can operate
over the Logger struct
func WithFileRotation ¶ added in v1.0.11
WithFileRotation sets up the option to roll log files
func WithStackTraceDepth ¶
WithStackTraceDepth sets up the stackTraceDepth option for the Logger
func WithStderrRedirect ¶ added in v1.0.11
func WithStderrRedirect() Option
WithStderrRedirect sets up the option to redirect stderr to file