@@ -54,9 +54,7 @@ const (
5454
5555 defaultConfigFilename = "lit.conf"
5656
57- defaultLogLevel = "info"
58- defaultMaxLogFiles = 3
59- defaultMaxLogFileSize = 10
57+ defaultLogLevel = "info"
6058
6159 defaultLetsEncryptSubDir = "letsencrypt"
6260 defaultLetsEncryptListen = ":80"
@@ -285,15 +283,17 @@ func (c *Config) lndConnectParams() (string, lndclient.Network, string,
285283
286284// defaultConfig returns a configuration struct with all default values set.
287285func defaultConfig () * Config {
286+ defaultLogCfg := build .DefaultLogConfig ()
288287 return & Config {
289288 HTTPSListen : defaultHTTPSListen ,
290289 TLSCertPath : DefaultTLSCertPath ,
291290 TLSKeyPath : defaultTLSKeyPath ,
292291 Remote : & subservers.RemoteConfig {
292+ LitLogConfig : defaultLogCfg ,
293293 LitDebugLevel : defaultLogLevel ,
294294 LitLogDir : defaultLogDir ,
295- LitMaxLogFiles : defaultMaxLogFiles ,
296- LitMaxLogFileSize : defaultMaxLogFileSize ,
295+ LitMaxLogFiles : defaultLogCfg . File . MaxLogFiles ,
296+ LitMaxLogFileSize : defaultLogCfg . File . MaxLogFileSize ,
297297 Lnd : & subservers.RemoteDaemonConfig {
298298 RPCServer : defaultRemoteLndRpcServer ,
299299 MacaroonPath : DefaultRemoteLndMacaroonPath ,
@@ -376,11 +376,21 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
376376 os .Exit (0 )
377377 }
378378
379+ // The logging config we use to initialise the sub-logger manager below
380+ // depends on whether we're running in remote mode or not.
381+ logCfg := preCfg .Lnd .LogConfig
382+ if preCfg .LndMode == ModeRemote {
383+ logCfg = preCfg .Remote .LitLogConfig
384+ }
385+
379386 // Before we validate the config, we first hook up our own loggers.
380387 // This must be done before the config is validated if LND is running
381388 // in integrated mode so that the log levels for various non-LND related
382389 // subsystems can be set via the `lnd.debuglevel` flag.
383- SetupLoggers (preCfg .Lnd .LogWriter , interceptor )
390+ preCfg .Lnd .SubLogMgr = build .NewSubLoggerManager (
391+ build .NewDefaultLogHandlers (logCfg , preCfg .Lnd .LogRotator )... ,
392+ )
393+ SetupLoggers (preCfg .Lnd .SubLogMgr , interceptor )
384394
385395 // Load the main configuration file and parse any command line options.
386396 // This function will also set up logging properly.
@@ -413,7 +423,7 @@ func loadAndValidateConfig(interceptor signal.Interceptor) (*Config, error) {
413423 debuglevel += fmt .Sprintf (",%s=off" , GrpcLogSubsystem )
414424 }
415425
416- err = build .ParseAndSetDebugLevels (debuglevel , cfg .Lnd .LogWriter )
426+ err = build .ParseAndSetDebugLevels (debuglevel , cfg .Lnd .SubLogMgr )
417427 if err != nil {
418428 return nil , err
419429 }
@@ -753,16 +763,34 @@ func validateRemoteModeConfig(cfg *Config) error {
753763
754764 r .LitLogDir = lncfg .CleanAndExpandPath (r .LitLogDir )
755765
766+ // Initialize the log manager with the actual logging configuration. We
767+ // need to support the deprecated max log files and max log file size
768+ // options for now.
769+ if r .LitMaxLogFiles != build .DefaultMaxLogFiles {
770+ log .Warnf ("Config option 'remote.lit-maxlogfiles' is " +
771+ "deprecated, please use " +
772+ "'remote.lit-logging.file.max-files' instead" )
773+
774+ r .LitLogConfig .File .MaxLogFiles = r .LitMaxLogFiles
775+ }
776+ if r .LitMaxLogFileSize != build .DefaultMaxLogFileSize {
777+ log .Warnf ("Config option 'remote.lit-maxlogfilesize' is " +
778+ "deprecated, please use " +
779+ "'remote.lit-logging.file.max-file-size' instead" )
780+
781+ r .LitLogConfig .File .MaxLogFileSize = r .LitMaxLogFileSize
782+ }
783+
756784 // In remote mode, we don't call lnd's ValidateConfig that sets up a
757785 // logging backend for us. We need to manually create and start one. The
758786 // root logger should've already been created as part of the default
759787 // config though.
760- if cfg .Lnd .LogWriter == nil {
761- cfg .Lnd .LogWriter = build .NewRotatingLogWriter ()
788+ if cfg .Lnd .LogRotator == nil {
789+ cfg .Lnd .LogRotator = build .NewRotatingLogWriter ()
762790 }
763- err := cfg .Lnd .LogWriter .InitLogRotator (
791+ err := cfg .Lnd .LogRotator .InitLogRotator (
792+ cfg .Remote .LitLogConfig .File ,
764793 filepath .Join (r .LitLogDir , cfg .Network , defaultLogFilename ),
765- r .LitMaxLogFileSize , r .LitMaxLogFiles ,
766794 )
767795 if err != nil {
768796 return fmt .Errorf ("log rotation setup failed: %v" , err .Error ())
0 commit comments