maillog

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MultiMessageSeparator = []byte("\n\n================================================================================\n\n")

MultiMessageSeparator used in WriteTo function in the message slice type to separate between multiple messages in a log file.

Functions

This section is empty.

Types

type Logger

type Logger struct {

	// MailDir writes mails into this directory. If set to "stderr" or "stdout"
	// then the output will be forwarded to those ports.
	MailDir string

	// ErrDir writes error log file into this directory. If set to "stderr" or
	// "stdout" then the output will be forwarded to those ports.
	ErrDir string

	// ErrFile full file path to the error log file
	ErrFile string
	// contains filtered or unexported fields
}

Logger logs emails and errors. If nil, nothing gets logged.

func New

func New(mailDir, errDir string) Logger

New creates a new logger by a given directory. If the directory does not exists it will be created recursively. Empty directory means a valid nil logger.

func (Logger) Errorf

func (l Logger) Errorf(format string, v ...interface{})

Errorf writes into the error log file. If the logger is nil no writes will happen.

func (Logger) Init

func (l Logger) Init(hosts ...string) (Logger, error)

Init creates directories and the error log file

func (Logger) IsNil

func (l Logger) IsNil() bool

IsNil returns true if the Logger is empty which means no paths are set.

func (Logger) NewWriter

func (l Logger) NewWriter() io.WriteCloser

NewWriter creates a new file with a file name consisting of a time stamp. If it fails to create a file it returns a nilWriteCloser and does not log anymore any data. Guaranteed to not return nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL