...

Package dugong

import "github.com/matrix-org/dugong"
Overview
Index

Overview ▾

func NewFSHook

func NewFSHook(infoPath, warnPath, errorPath string, formatter log.Formatter, rotSched RotationScheduler) log.Hook

NewFSHook makes a logging hook that writes formatted log entries to info, warn and error log files. Each log file contains the messages with that severity or higher. If a formatter is not specified, they will be logged using a JSON formatter. If a RotationScheduler is set, the files will be cycled according to its rules.

type DailyRotationSchedule

type DailyRotationSchedule struct {
    GZip bool
    // contains filtered or unexported fields
}

DailyRotationSchedule rotates log files daily. Logs are only rotated when midnight passes *whilst the process is running*. E.g: if you run the process on Day 4 then stop it and start it on Day 7, no rotation will occur when the process starts.

func (*DailyRotationSchedule) ShouldGZip

func (rs *DailyRotationSchedule) ShouldGZip() bool

func (*DailyRotationSchedule) ShouldRotate

func (rs *DailyRotationSchedule) ShouldRotate() (bool, string)

type RotationScheduler

type RotationScheduler interface {
    // ShouldRotate returns true if the file should be rotated. The suffix to apply
    // to the filename is returned as the 2nd arg.
    ShouldRotate() (bool, string)
    // ShouldGZip returns true if the file should be gzipped when it is rotated.
    ShouldGZip() bool
}

RotationScheduler determines when files should be rotated.