Documentation
¶
Overview ¶
Package handler provides some commonly used handlers。 such as: file, mail, syslog and more
Index ¶
Constants ¶
const ( FlushModeTicker = iota + 1 FlushModeLimit )
available FlushMode values
const ( FilePerDay string = "2006-01-02" FilePerMonth string = "2006-01" FilePerYear string = "2006" )
some rotating date formats
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct { Handler // contains filtered or unexported fields }
Buffer struct definition
func (*Buffer) HandleBatch ¶
HandleBatch Handles a set of records.
type File ¶
File handler.
type Filter ¶
type Filter struct { Handler Processable // contains filtered or unexported fields }
Filter struct definition
func (*Filter) GetAcceptedLevels ¶
GetAcceptedLevels Get acceptedLevels
func (*Filter) HandleBatch ¶
HandleBatch log records
func (*Filter) IsHandling ¶
IsHandling Is Handling
type Formattable ¶
type Formattable struct {
// contains filtered or unexported fields
}
Formattable struct definition
func (*Formattable) GetDefaultFormatter ¶
func (f *Formattable) GetDefaultFormatter() types.Formatter
GetDefaultFormatter Gets the default formatter.
func (*Formattable) GetFormatter ¶
func (f *Formattable) GetFormatter() types.Formatter
GetFormatter Get formatter
func (*Formattable) SetFormatter ¶
func (f *Formattable) SetFormatter(formatter types.Formatter)
SetFormatter Set formatter
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler struct definition
func (*Handler) IsHandling ¶
IsHandling Checks whether the given record will be handled by this handler.
type Mail ¶
type Mail struct { Processing Addr string // SMTP server address Username string // SMTP server login username Password string // SMTP server login password Subject string // The subject of the email From string // The sender of the mail To []string // The email addresses to which the message will be sent // contains filtered or unexported fields }
Mail handler struct definition
func NewMail ¶
func NewMail(address, username, password, from, subject string, to []string, level int, bubble bool) *Mail
NewMail new mail handler
func (*Mail) ContentType ¶
ContentType Get the content type of the email - Defaults to text/plain. Use text/html for HTML
func (*Mail) SetContentType ¶
SetContentType Set the content type of the email - Defaults to text/plain. Use text/html for HTML
func (*Mail) SetEncoding ¶
SetEncoding Set the encoding for the message - Defaults to UTF-8
type Net ¶
type Net struct { Processing // Known networks are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only), // "udp", "udp4" (IPv4-only), "udp6" (IPv6-only), "ip", "ip4" // (IPv4-only), "ip6" (IPv6-only), "unix", "unixgram" and // "unixpacket". Network string Address string Persistent bool BufferSize int // contains filtered or unexported fields }
Net handler struct definition
type Processable ¶
type Processable struct {
// contains filtered or unexported fields
}
Processable struct definition
func (*Processable) PopProcessor ¶
func (p *Processable) PopProcessor() types.Processor
PopProcessor pop processor
func (*Processable) ProcessRecord ¶
func (p *Processable) ProcessRecord(record *types.Record)
ProcessRecord Processes a record.
func (*Processable) PushProcessor ¶
func (p *Processable) PushProcessor(types.Processor)
PushProcessor push processor
type Processing ¶
type Processing struct { Handler Processable Formattable Writer func(*types.Record) }
Processing struct definition
func (*Processing) HandleBatch ¶
func (p *Processing) HandleBatch(records []*types.Record)
HandleBatch Handles a set of records.
type RotatingFile ¶
RotatingFile Stores logs to files that are rotated every day and a limited number of files are kept.
This rotation is only intended to be used as a workaround. Using logrotate to handle the rotation is strongly encouraged when you can use it.
func NewRotatingFile ¶
func NewRotatingFile(filename string, filePerm os.FileMode, maxFiles, level int, bubble bool) *RotatingFile
NewRotatingFile New rotatingFile handler level: The minimum logging level at which this handler will be triggered bubble: Whether the messages that are handled can bubble up the stack or not filePerm: Optional file permissions (default (0644) are only for owner read/write)
func (*RotatingFile) SetFilenameFormat ¶
func (rf *RotatingFile) SetFilenameFormat(filenameFormat, dateFormat string) error
SetFilenameFormat Set filename format.
type Syslog ¶
type Syslog struct { Processing SysWriter *syslog.Writer }
Syslog struct definition
func NewSyslog ¶
NewSyslog New establishes a new connection to the system log daemon. Each write to the returned writer sends a log message with the given priority (a combination of the syslog facility and severity) and prefix tag. If tag is empty, the os.Args[0] is used.
func (*Syslog) GetDefaultFormatter ¶
GetDefaultFormatter Gets the default syslog formatter.