Documentation ¶
Index ¶
- Constants
- type FileTarget
- type Level
- type Logger
- func (l *Logger) Close() error
- func (l *Logger) Debug(message string)
- func (l *Logger) Debugf(format string, a ...interface{})
- func (l *Logger) Error(message string)
- func (l *Logger) Errorf(format string, a ...interface{})
- func (l *Logger) Fatal(message string)
- func (l *Logger) Fatalf(format string, a ...interface{})
- func (l *Logger) Info(message string)
- func (l *Logger) Infof(format string, a ...interface{})
- func (l *Logger) Panic(message string)
- func (l *Logger) Panicf(format string, a ...interface{})
- func (l *Logger) Print(level Level, message string)
- func (l *Logger) Printf(level Level, format string, a ...interface{})
- func (l *Logger) SetLevel(level Level)
- func (l *Logger) SetTarget(target Target)
- type Option
- type SyslogTarget
- type Target
- type Writer
Constants ¶
View Source
const ( TargetStderr = "stderr" TargetStdout = "stdout" TargetSyslog = "syslog" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FileTarget ¶
type FileTarget struct {
// contains filtered or unexported fields
}
func NewFileTarget ¶
func NewFileTarget(writer io.Writer) *FileTarget
Create a new file writer pointing to the provided open file.
func OpenFileTarget ¶
func OpenFileTarget(file string) (*FileTarget, error)
Create a new file writer pointing to the file at the provided path.
func (*FileTarget) Write ¶
func (s *FileTarget) Write(level Level, message string)
Print a log message to the writer.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
type Option ¶
var ConsoleOpt Option = func(logger *Logger) error { logger.target = NewFileTarget(os.Stderr) return nil }
Create a console target option to configure the logger.
var SyslogOpt Option = func(logger *Logger) error { target, err := NewSyslogTarget() if err == nil { logger.target = target } return err }
Create a syslog option to configure the logger.
func NewLevelOpt ¶
Create a level option to configure the logger.
func NewTargetOpt ¶
Create a target option to configure the logger.
type SyslogTarget ¶
type SyslogTarget struct {
// contains filtered or unexported fields
}
Write log messages to syslog.
func NewRemoteTarget ¶
func NewRemoteTarget(network, raddr string) (*SyslogTarget, error)
Create a remote syslog writer.
func (*SyslogTarget) Write ¶
func (s *SyslogTarget) Write(level Level, message string)
Print a log message to the writer.
type Target ¶
Targets are where the logger sends filtered log messages. They can be created by a TargetOpt.
Click to show internal directories.
Click to hide internal directories.