filelog

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2015 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package log/filelog implements advanced writer to log files for "log4go" package with improved algorithm of log rotation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Represents log writer which writes logs into files. It can rotate files and delete previously rotated but expired now logs.

func NewWriter

func NewWriter(fName string, rotate bool) *Writer

Initializes new log writer.

func (*Writer) Close

func (w *Writer) Close()

Closes current log writer and resources connected with it. By default acts asynchronous, which means that method doesn't wait log writer to be closed. To change this behaviour you must use .SetWaitOnClose() method.

Implementation of log4go.LogWriter interface.

func (*Writer) LogWrite

func (w *Writer) LogWrite(rec *log.LogRecord)

Writes given log record into file.

Implementation of log4go.LogWriter interface.

func (*Writer) Rotate

func (w *Writer) Rotate()

Manual request for current log rotation.

func (*Writer) SetFormat

func (w *Writer) SetFormat(format string) *Writer

Sets the logging format (chainable). Must be called before the first log message is written.

func (*Writer) SetHeadFoot

func (w *Writer) SetHeadFoot(head, foot string) *Writer

Sets the log file header and footer (chainable). Must be called before the first log message is written. These are formatted similar to the log4go.FormatLogRecord (e.g. you can use %D and %T in your header/footer for date and time).

func (*Writer) SetRotate

func (w *Writer) SetRotate(rotate bool) *Writer

Changes whether or not the old logs are kept (chainable). Must be called before the first log message is written. If rotate is false, the files are overwritten; otherwise, they are rotated to another file before the new log is opened.

func (*Writer) SetRotateDaily

func (w *Writer) SetRotateDaily(daily bool) *Writer

Sets rotate daily (chainable). Must be called before the first log message is written.

func (*Writer) SetRotateLines

func (w *Writer) SetRotateLines(maxlines int) *Writer

Sets rotate at linecount (chainable). Must be called before the first log message is written.

func (*Writer) SetRotateSize

func (w *Writer) SetRotateSize(maxsize int) *Writer

Sets rotate at size (chainable). Must be called before the first log message is written.

func (*Writer) SetRotatedFilesExpiration

func (w *Writer) SetRotatedFilesExpiration(seconds uint64) *Writer

Sets duration (in seconds) of how long already rotated files must be kept (chainable). If is not set, then files will be kept always.

func (*Writer) SetWaitOnClose

func (w *Writer) SetWaitOnClose(yes bool) *Writer

Makes .Close() method to wait until Writer will be totally closed. If is not set, by default is false, which means .Close() method to act asynchronous.

Jump to

Keyboard shortcuts

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