Documentation
¶
Overview ¶
Package email allows for log messages to be sent via email.
Example ¶
simple email
package main import ( "github.com/go-playground/log" "github.com/go-playground/log/handlers/email" ) func main() { email := email.New("smtp.gmail.com", 587, "username", "password", "from@email.com", []string{"to@email.com"}) email.SetFilenameDisplay(log.Llongfile) log.RegisterHandler(email, log.WarnLevel, log.AlertLevel, log.PanicLevel) log.WithFields(log.F("error", "something went wrong")).StackTrace().Alert("ALERT!") }
Index ¶
- type Email
- func (email *Email) From() string
- func (email *Email) Run() chan<- *log.Entry
- func (email *Email) SetBuffersAndWorkers(size uint, workers uint)
- func (email *Email) SetEmailTemplate(htmlTemplate string)
- func (email *Email) SetFilenameDisplay(fd log.FilenameDisplay)
- func (email *Email) SetFormatFunc(fn FormatFunc)
- func (email *Email) SetKeepAliveTimout(keepAlive time.Duration)
- func (email *Email) SetTimestampFormat(format string)
- func (email *Email) Template() *template.Template
- func (email *Email) To() []string
- type FormatFunc
- type Formatter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Email ¶
type Email struct {
// contains filtered or unexported fields
}
Email is an instance of the email logger
func (*Email) 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 (*Email) SetEmailTemplate ¶
SetEmailTemplate sets Email's html template to be used for email body
func (*Email) SetFilenameDisplay ¶
func (email *Email) SetFilenameDisplay(fd log.FilenameDisplay)
SetFilenameDisplay tells Email the filename, when present, how to display
func (*Email) SetFormatFunc ¶
func (email *Email) SetFormatFunc(fn FormatFunc)
SetFormatFunc sets FormatFunc each worker will call to get a Formatter func
func (*Email) SetKeepAliveTimout ¶
SetKeepAliveTimout tells Email how long to keep the smtp connection open when no messsages are being sent; it will automatically reconnect on next message that is received.
func (*Email) SetTimestampFormat ¶
SetTimestampFormat sets Email's timestamp output format Default is : "2006-01-02T15:04:05.000000000Z07:00"
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.