Documentation ¶
Index ¶
- Constants
- type BaseConfig
- type FileConfig
- type Level
- type Logger
- func NewFileLogger(conf *FileConfig) (Logger, io.Closer, error)
- func NewMultiLogger(loggers ...Logger) Logger
- func NewStderrLogger(conf *WriterConfig) (Logger, error)
- func NewTestLogger(conf *WriterConfig, verbose bool) (Logger, error)
- func NewWriterLogger(conf *WriterConfig, out io.Writer) (Logger, error)
- type LoggerBase
- type LoggerFunc
- type WriterConfig
Constants ¶
const ( // CRC16("github.com/privatix/dappctrl/util/log") = 0x6928 ErrBadLevel errors.Error = 0x6928<<8 + iota ErrBadStackLevel )
Errors.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BaseConfig ¶
BaseConfig is a configuration for LoggerBase.
func NewBaseConfig ¶
func NewBaseConfig() *BaseConfig
NewBaseConfig creates a new LoggerBase configuration.
type FileConfig ¶
type FileConfig struct { *WriterConfig Filename string FileMode os.FileMode }
FileConfig is a file based logger configuration.
func NewFileConfig ¶
func NewFileConfig() *FileConfig
NewFileConfig creates a new file logger configuration.
type Logger ¶
type Logger interface { Add(vars ...interface{}) Logger Log(lvl Level, msg string) Debug(msg string) Info(msg string) Warn(msg string) Error(msg string) Fatal(msg string) }
Logger is an interface for loggers.
func NewFileLogger ¶
func NewFileLogger(conf *FileConfig) (Logger, io.Closer, error)
NewFileLogger creates a new file logger.
func NewMultiLogger ¶
NewMultiLogger creates a new multi-logger from given loggers.
func NewStderrLogger ¶
func NewStderrLogger(conf *WriterConfig) (Logger, error)
NewStderrLogger creates a new logger for standard error stream.
func NewTestLogger ¶
func NewTestLogger(conf *WriterConfig, verbose bool) (Logger, error)
NewTestLogger creates a new test logger.
func NewWriterLogger ¶
func NewWriterLogger(conf *WriterConfig, out io.Writer) (Logger, error)
NewWriterLogger creates a new io.Writer based logger.
type LoggerBase ¶
type LoggerBase struct {
// contains filtered or unexported fields
}
LoggerBase is a base logger implementation shared by many other loggers.
func NewLoggerBase ¶
func NewLoggerBase(conf *BaseConfig, log LoggerFunc) (*LoggerBase, error)
NewLoggerBase creates a new LoggerBase.
func (*LoggerBase) Add ¶
func (l *LoggerBase) Add(vars ...interface{}) Logger
Add returns a new logger with added context variables. This function takes alternated key-value pairs (name1, val1, name1, val2, ...). The keys must be strings, but the values can be of any type.
func (*LoggerBase) Fatal ¶
func (l *LoggerBase) Fatal(msg string)
Fatal adds a new fatal message and then panics.
func (*LoggerBase) Log ¶
func (l *LoggerBase) Log(lvl Level, msg string)
Log adds a new log message with a given severity level.
type LoggerFunc ¶
LoggerFunc is a low-level logging function.
type WriterConfig ¶
type WriterConfig struct { *BaseConfig Prefix string UTC bool }
WriterConfig is an io.Writer based logger configuration.
func NewWriterConfig ¶
func NewWriterConfig() *WriterConfig
NewWriterConfig creates a new io.Writer based logger configuration.