From 6f0cd4afd76b26aecf6e3d3dda52916eaf87e0f2 Mon Sep 17 00:00:00 2001 From: Edouard Paris Date: Sat, 13 Apr 2019 17:52:33 +0200 Subject: [PATCH] fix logger: use default development --- README.md | 5 ++++- app/app.go | 5 ++++- logging/logging.go | 18 ++++++++---------- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 4f6ca1d..fd15f24 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,9 @@ If you prefer to run `lntop` from a docker container: cd docker # now you should review ./lntop/home/initial-config.toml +# if you have an existing .lntop directory, you can export it +# export LNTOP_HOME=~/.lntop +# ! change path to files in .lntop/config with user current directory /root ! # point LND_HOME to your actual lnd directory # we recommend using .envrc with direnv @@ -59,7 +62,7 @@ export LND_HOME=~/.lnd # run lntop from the container ./lntop.sh -# lntop data will be mapped to host folder at ./_volumes/lntop-data +# lntop data will be mapped to host folder at ./_volumes/lntop-data ``` To see `lntop` logs, you can tail them in another terminal session via: diff --git a/app/app.go b/app/app.go index d556a8d..85ab5c8 100644 --- a/app/app.go +++ b/app/app.go @@ -13,7 +13,10 @@ type App struct { } func New(cfg *config.Config) (*App, error) { - logger := logging.New(cfg.Logger) + logger, err := logging.New(cfg.Logger) + if err != nil { + return nil, err + } network, err := network.New(&cfg.Network, logger) if err != nil { diff --git a/logging/logging.go b/logging/logging.go index 3e46fd0..ff2c7cb 100644 --- a/logging/logging.go +++ b/logging/logging.go @@ -43,17 +43,15 @@ func Object(key string, val zapcore.ObjectMarshaler) Field { return zap.Object(key, val) } -func New(cfg config.Logger) Logger { - var logger Logger - if cfg.Type == "development" { - logger, _ = NewDevelopmentLogger(cfg.Dest) - } else if cfg.Type == "noop" { - logger, _ = NewNopLogger() - } else { - logger, _ = NewProductionLogger(cfg.Dest) +func New(cfg config.Logger) (Logger, error) { + switch cfg.Type { + case "development": + return NewDevelopmentLogger(cfg.Dest) + case "production": + return NewProductionLogger(cfg.Dest) + default: + return NewDevelopmentLogger(cfg.Dest) } - - return logger } func NewProductionLogger(dest string) (Logger, error) {