diff --git a/api/geth_backend.go b/api/geth_backend.go index e95b09348d4..c001e18c782 100644 --- a/api/geth_backend.go +++ b/api/geth_backend.go @@ -271,6 +271,22 @@ func (b *GethStatusBackend) ensureAppDBOpened(account multiaccounts.Account, pas return nil } +func (b *GethStatusBackend) setupLogSettings() error { + logSettings := logutils.LogSettings{ + Enabled: b.config.LogEnabled, + MobileSystem: b.config.LogMobileSystem, + Level: b.config.LogLevel, + File: b.config.LogFile, + MaxSize: b.config.LogMaxSize, + MaxBackups: b.config.LogMaxBackups, + CompressRotated: b.config.LogCompressRotated, + } + if err := logutils.OverrideRootLogWithConfig(logSettings, false); err != nil { + return err + } + return nil +} + // StartNodeWithKey instead of loading addresses from database this method derives address from key // and uses it in application. // TODO: we should use a proper struct with optional values instead of duplicating the regular functions @@ -281,20 +297,13 @@ func (b *GethStatusBackend) startNodeWithKey(acc multiaccounts.Account, password return err } - if b.loadNodeConfig(nil) != nil { + err = b.loadNodeConfig(nil) + if err != nil { return err } - logSettings := logutils.LogSettings{ - Enabled: b.config.LogEnabled, - MobileSystem: b.config.LogMobileSystem, - Level: b.config.LogLevel, - File: b.config.LogFile, - MaxSize: b.config.LogMaxSize, - MaxBackups: b.config.LogMaxBackups, - CompressRotated: b.config.LogCompressRotated, - } - if err := logutils.OverrideRootLogWithConfig(logSettings, false); err != nil { + err = b.setupLogSettings() + if err != nil { return err } @@ -372,18 +381,11 @@ func (b *GethStatusBackend) startNodeWithAccount(acc multiaccounts.Account, pass return err } - logSettings := logutils.LogSettings{ - Enabled: b.config.LogEnabled, - MobileSystem: b.config.LogMobileSystem, - Level: b.config.LogLevel, - File: b.config.LogFile, - MaxSize: b.config.LogMaxSize, - MaxBackups: b.config.LogMaxBackups, - CompressRotated: b.config.LogCompressRotated, - } - if err := logutils.OverrideRootLogWithConfig(logSettings, false); err != nil { + err = b.setupLogSettings() + if err != nil { return err } + b.account = &acc accountsDB, err := accounts.NewDB(b.appDB) if err != nil {