mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-08-27 22:21:18 +02:00
build+config: add default handler constructor
Since most of our projects will use the same handler duo and apply the config options the same way, let's make our lives easier and add a default handler constructor.
This commit is contained in:
23
build/handlers.go
Normal file
23
build/handlers.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package build
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/btcsuite/btclog/v2"
|
||||
)
|
||||
|
||||
// NewDefaultLogHandlers returns the standard console logger and rotating log
|
||||
// writer handlers that we generally want to use. It also applies the various
|
||||
// config options to the loggers.
|
||||
func NewDefaultLogHandlers(cfg *LogConfig, rotator *RotatingLogWriter) (
|
||||
btclog.Handler, btclog.Handler) {
|
||||
|
||||
consoleLogHandler := btclog.NewDefaultHandler(
|
||||
os.Stdout, cfg.Console.HandlerOptions()...,
|
||||
)
|
||||
logFileHandler := btclog.NewDefaultHandler(
|
||||
rotator, cfg.File.HandlerOptions()...,
|
||||
)
|
||||
|
||||
return consoleLogHandler, logFileHandler
|
||||
}
|
Reference in New Issue
Block a user