lhm

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2021 License: BSD-2-Clause Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

LHM - LogHandleMap

Documentation

Overview

Package lhm implements a loghandle map to manage multiple loggers with file reopen support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogHandleMap

type LogHandleMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

LogHandleMap is a concurrent map that is used to look up filehandles of active logfiles

func Init added in v0.0.2

func Init() *LogHandleMap

Init returns are barebone LogHandleMap

func New

func New(basepath string) (*LogHandleMap, *chan os.Signal)

New returns an initialized LogHandleMap

func (*LogHandleMap) Add

func (x *LogHandleMap) Add(key string, fh *reopen.FileWriter, lg *logrus.Logger)

Add registers a new filehandle

func (*LogHandleMap) Del

func (x *LogHandleMap) Del(key string)

Del removes a filehandle

func (*LogHandleMap) EarlyFatal added in v0.0.2

func (x *LogHandleMap) EarlyFatal(args ...interface{})

EarlyFatal exposes logrus.Fatal on the __early logger created via Init().

func (*LogHandleMap) EarlyPrintf added in v0.0.2

func (x *LogHandleMap) EarlyPrintf(format string, args ...interface{})

EarlyPrintf exposes logrus.Printf on the __early logger created via Init().

func (*LogHandleMap) GetFileHandle

func (x *LogHandleMap) GetFileHandle(key string) *reopen.FileWriter

GetFileHandle retrieves a filehandle

func (*LogHandleMap) GetLogger

func (x *LogHandleMap) GetLogger(key string) *logrus.Logger

GetLogger retrieves a logger

func (*LogHandleMap) Open

func (x *LogHandleMap) Open(fname string, lvl logrus.Level) (err error)

Open creates a new logger with registration name fname, backed by fname.log at the registered basepath

func (*LogHandleMap) Reopen

func (x *LogHandleMap) Reopen(ignorePrefix string, abortFunc func(e error))

Reopen should be called inside a go-routine. Inside is an infinite loop that waits for a signal delivered via the channel returned by New(). Whenever a signal is received, it cycles through all registered logfile handles and reopens them, unless their registration names starts with ignorePrefix. If a reopen operation fails, the error is passed to abortFunc and no further handles are reopened.

func (*LogHandleMap) Setup added in v0.0.2

func (x *LogHandleMap) Setup(basepath string) *chan os.Signal

Setup upgrades a LogHandleMap created via Init() into a full map.

Jump to

Keyboard shortcuts

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