package rotatefilehook

import "github.com/oslokommune/okctl/pkg/rotatefilehook"

Package rotatefilehook implements a rotating file logger for logrus

Index

Functions

func NewRotateFileHook

func NewRotateFileHook(config RotateFileConfig) (logrus.Hook, error)

NewRotateFileHook returns a hook that writes to a log file and rotates it

Types

type RotateFileConfig

type RotateFileConfig struct {
	Filename   string
	MaxSize    int
	MaxBackups int
	MaxAge     int
	Levels     []logrus.Level
	Formatter  logrus.Formatter
}

RotateFileConfig contains the configuration

type RotateFileHook

type RotateFileHook struct {
	Config RotateFileConfig
	// contains filtered or unexported fields
}

RotateFileHook saves the state of the logger

func (*RotateFileHook) Fire

func (hook *RotateFileHook) Fire(entry *logrus.Entry) error

Fire writes to the file

func (*RotateFileHook) Levels

func (hook *RotateFileHook) Levels() []logrus.Level

Levels returns the loglevels

Source Files

rotatefilehook.go

Version
v0.0.106 (latest)
Published
Oct 21, 2022
Platform
linux/amd64
Imports
3 packages
Last checked
18 hours ago

Tools for package owners.