hooks

package module
Version: v0.0.0-...-6973c2a Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2018 License: MIT Imports: 8 Imported by: 1

README

logrus-hooks

  • Rotate Hook, rotate the log file by daily(default) or hour
  • Source Hook, append the caller to log's message

How to use

package main

import (
    "github.com/Sirupsen/logrus"
    hooks "github.com/git-hulk/logrus-hooks"
)

func main() {
    logger := logrus.New()
    // Create rotate hook
    rotateHook, err := hooks.NewRotateHook(logger, "/www/mydir", "test")
    if err != nil {
        // do something and exit
    }
    logger.Hooks.Add(rotateHook)
    // Create source hook
    logger.Hooks.Add(hooks.NewSourceHook(logrus.InfoLevel))
    logger.Info("foo")
}

Documentation

Index

Constants

View Source
const (
	RotateByDay = iota
	RotateByHour
)

Variables

This section is empty.

Functions

func ReleaseRotateHook

func ReleaseRotateHook(rh *RotateHook)

Types

type RotateHook

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

func NewRotateHook

func NewRotateHook(logger *logrus.Logger, dir, name string) (*RotateHook, error)

func (*RotateHook) Fire

func (rh *RotateHook) Fire(entry *logrus.Entry) error

func (*RotateHook) Levels

func (rh *RotateHook) Levels() []logrus.Level

func (*RotateHook) SetRotateType

func (rh *RotateHook) SetRotateType(rtype int)

type SourceHook

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

func NewSourceHook

func NewSourceHook(level logrus.Level) *SourceHook

func (*SourceHook) Fire

func (sh *SourceHook) Fire(entry *logrus.Entry) error

func (*SourceHook) Levels

func (sh *SourceHook) Levels() []logrus.Level

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL