lnd+build: add logcompressor flag

This commit is contained in:
Jonathan Harvey-Buschel committed 2024-09-12 12:31:02 -04:00
1 parent 750770e190
commit f360532eb1
3 files changed
+37

No files matched your search

+8
View File
@@ -59,6 +59,7 @@ const (
defaultLogLevel = "info"
defaultLogDirname = "logs"
defaultLogFilename = "lnd.log"
defaultLogCompressor = build.Gzip
defaultRPCPort = 10009
defaultRESTPort = 8080
defaultPeerPort = 9735
@@ -315,6 +316,7 @@ type Config struct {
ReadMacPath string `long:"readonlymacaroonpath" description:"Path to write the read-only macaroon for lnd's RPC and REST services if it doesn't exist"`
InvoiceMacPath string `long:"invoicemacaroonpath" description:"Path to the invoice-only macaroon for lnd's RPC and REST services if it doesn't exist"`
LogDir string `long:"logdir" description:"Directory to log output."`
LogCompressor string `long:"logcompressor" description:"Compression algorithm to use when rotating logs." choice:"gzip" choice:"zstd"`
MaxLogFiles int `long:"maxlogfiles" description:"Maximum logfiles to keep (0 for no rotation)"`
MaxLogFileSize int `long:"maxlogfilesize" description:"Maximum logfile size in MB"`
AcceptorTimeout time.Duration `long:"acceptortimeout" description:"Time after which an RPCAcceptor will time out and return false if it hasn't yet received a response"`
@@ -560,6 +562,7 @@ func DefaultConfig() Config {
LetsEncryptDir: defaultLetsEncryptDir,
LetsEncryptListen: defaultLetsEncryptListen,
LogDir: defaultLogDir,
LogCompressor: defaultLogCompressor,
MaxLogFiles: defaultMaxLogFiles,
MaxLogFileSize: defaultMaxLogFileSize,
AcceptorTimeout: defaultAcceptorTimeout,
@@ -1446,6 +1449,11 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
os.Exit(0)
}
if !build.SuportedLogCompressor(cfg.LogCompressor) {
return nil, mkErr("invalid log compressor: %v",
cfg.LogCompressor)
}
// Initialize logging at the default logging level.
SetupLoggers(cfg.LogWriter, interceptor)
err = cfg.LogWriter.InitLogRotator(