Documentation ¶
Overview ¶
Package syslog allows for log messages to be sent via syslog.
Example ¶
NOTE: syslog uses github.com/RackSec/srslog as the stdlib syslog
is no longer being maintained or added to as of this discussion https://github.com/golang/go/issues/13449#issuecomment-161204716 package main import ( stdsyslog "log/syslog" "github.com/go-playground/log" "github.com/go-playground/log/handlers/syslog" ) func main() { sysLog, err := syslog.New("udp", "log.logs.com:4863", stdsyslog.LOG_DEBUG, "") if err != nil { // handle error } sysLog.SetFilenameDisplay(log.Llongfile) log.RegisterHandler(sysLog, log.AllLevels...) // Trace defer log.Trace("trace").End() log.Debug("debug") log.Info("info") log.Notice("notice") log.Warn("warn") log.Error("error") // log.Panic("panic") // this will panic log.Alert("alert") // log.Fatal("fatal") // this will call os.Exit(1) // logging with fields can be used with any of the above log.WithFields(log.F("key", "value")).Info("test info") }
Index ¶
- type FormatFunc
- type Formatter
- type Syslog
- func (s *Syslog) DisplayColor() bool
- func (s *Syslog) FilenameDisplay() log.FilenameDisplay
- func (s *Syslog) GOPATH() string
- func (s *Syslog) GetDisplayColor(level log.Level) ansi.EscSeq
- func (s *Syslog) Run() chan<- *log.Entry
- func (s *Syslog) SetBuffersAndWorkers(size uint, workers uint)
- func (s *Syslog) SetDisplayColor(color bool)
- func (s *Syslog) SetFilenameDisplay(fd log.FilenameDisplay)
- func (s *Syslog) SetFormatFunc(fn FormatFunc)
- func (s *Syslog) SetTimestampFormat(format string)
- func (s *Syslog) TimestampFormat() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FormatFunc ¶
FormatFunc is the function that the workers use to create a new Formatter per worker allowing reusable go routine safe variable to be used within your Formatter function.
type Syslog ¶
type Syslog struct {
// contains filtered or unexported fields
}
Syslog is an instance of the syslog logger
func New ¶
New returns a new instance of the syslog logger example: syslog.New("udp", "localhost:514", syslog.LOG_DEBUG, "", nil) NOTE: tlsConfig param is optional and only applies when networks in "tcp+tls" see TestSyslogTLS func tion int syslog_test.go for an example usage of tlsConfig parameter
func (*Syslog) DisplayColor ¶
DisplayColor returns if logging color or not
func (*Syslog) FilenameDisplay ¶
func (s *Syslog) FilenameDisplay() log.FilenameDisplay
FilenameDisplay returns Syslog's current filename display setting
func (*Syslog) GetDisplayColor ¶
GetDisplayColor returns the color for the given log level
func (*Syslog) SetBuffersAndWorkers ¶
SetBuffersAndWorkers sets the channels buffer size and number of concurrent workers. These settings should be thought about together, hence setting both in the same function.
func (*Syslog) SetDisplayColor ¶
SetDisplayColor tells Syslog to output in color or not Default is : true
func (*Syslog) SetFilenameDisplay ¶
func (s *Syslog) SetFilenameDisplay(fd log.FilenameDisplay)
SetFilenameDisplay tells Syslog the filename, when present, how to display
func (*Syslog) SetFormatFunc ¶
func (s *Syslog) SetFormatFunc(fn FormatFunc)
SetFormatFunc sets FormatFunc each worker will call to get a Formatter func
func (*Syslog) SetTimestampFormat ¶
SetTimestampFormat sets Syslog's timestamp output format Default is : 2006-01-02T15:04:05.000000000Z07:00
func (*Syslog) TimestampFormat ¶
TimestampFormat returns Syslog's current timestamp output format