Documentation
¶
Overview ¶
Package lhm implements a loghandle map to manage multiple loggers with file reopen support.
Index ¶
- type LogHandleMap
- func (x *LogHandleMap) Add(key string, fh *reopen.FileWriter, lg *logrus.Logger)
- func (x *LogHandleMap) Del(key string)
- func (x *LogHandleMap) EarlyFatal(args ...interface{})
- func (x *LogHandleMap) EarlyPrintf(format string, args ...interface{})
- func (x *LogHandleMap) GetFileHandle(key string) *reopen.FileWriter
- func (x *LogHandleMap) GetLogger(key string) *logrus.Logger
- func (x *LogHandleMap) Open(fname string, lvl logrus.Level) (err error)
- func (x *LogHandleMap) Reopen(ignorePrefix string, abortFunc func(e error))
- func (x *LogHandleMap) Setup(basepath string) *chan os.Signal
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogHandleMap ¶
LogHandleMap is a concurrent map that is used to look up filehandles of active logfiles
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) 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.