lfshook: github.com/rifflock/lfshook Index | Files

package lfshook

import "github.com/rifflock/lfshook"

Package lfshook is hook for sirupsen/logrus that used for writing the logs to local files.

Index

Package Files

lfshook.go

type LfsHook Uses

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

LfsHook is a hook to handle writing to local log files.

func NewHook Uses

func NewHook(output interface{}, formatter logrus.Formatter) *LfsHook

NewHook returns new LFS hook. Output can be a string, io.Writer, WriterMap or PathMap. If using io.Writer or WriterMap, user is responsible for closing the used io.Writer.

func (*LfsHook) Fire Uses

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

Fire writes the log file to defined path or using the defined writer. User who run this function needs write permissions to the file or directory if the file does not yet exist.

func (*LfsHook) Levels Uses

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

Levels returns configured log levels.

func (*LfsHook) SetDefaultPath Uses

func (hook *LfsHook) SetDefaultPath(defaultPath string)

SetDefaultPath sets default path for levels that don't have any defined output path.

func (*LfsHook) SetDefaultWriter Uses

func (hook *LfsHook) SetDefaultWriter(defaultWriter io.Writer)

SetDefaultWriter sets default writer for levels that don't have any defined writer.

func (*LfsHook) SetFormatter Uses

func (hook *LfsHook) SetFormatter(formatter logrus.Formatter)

SetFormatter sets the format that will be used by hook. If using text formatter, this method will disable color output to make the log file more readable.

type PathMap Uses

type PathMap map[logrus.Level]string

PathMap is map for mapping a log level to a file's path. Multiple levels may share a file, but multiple files may not be used for one level.

type WriterMap Uses

type WriterMap map[logrus.Level]io.Writer

WriterMap is map for mapping a log level to an io.Writer. Multiple levels may share a writer, but multiple writers may not be used for one level.

Package lfshook imports 8 packages (graph) and is imported by 104 packages. Updated 2018-09-20. Refresh now. Tools for package owners.