Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultMailHost = `` DefaultMailUsername = `` DefaultMailPassword = `` DefaultMailSubject = `` DefaultMailSender = `` DefaultMailRecipients = []string{} )
Functions ¶
This section is empty.
Types ¶
type MailTarget ¶
type MailTarget struct {
*log.Filter
Host string // SMTP server address
Username string // SMTP server login username
Password string // SMTP server login password
Subject string // the mail subject
Sender string // the mail sender
Recipients []string // the mail recipients
BufferSize int // the size of the message channel.
// contains filtered or unexported fields
}
MailTarget sends log messages in emails via an SMTP server.
func NewMailTarget ¶
func NewMailTarget() *MailTarget
NewMailTarget creates a MailTarget. The new MailTarget takes these default options: MaxLevel: LevelDebug, BufferSize: 1024. You must specify these fields: Host, Username, Subject, Sender, and Recipients.
Example ¶
logger := log.NewLogger()
// creates a MailTarget which sends emails to admin@example.com
target := NewMailTarget()
target.Host = "smtp.example.com"
target.Username = "foo"
target.Password = "bar"
target.Subject = "log messages for foobar"
target.Sender = "admin@example.com"
target.Recipients = []string{"admin@example.com"}
logger.Targets = append(logger.Targets, target)
logger.Open()
// ... logger is ready to use ...
func (*MailTarget) Open ¶
func (t *MailTarget) Open(errWriter io.Writer) error
Open prepares MailTarget for processing log messages.
func (*MailTarget) Process ¶
func (t *MailTarget) Process(e *log.Entry)
Process puts filtered log messages into a channel for sending in emails.
Click to show internal directories.
Click to hide internal directories.