From d80ef40f1a547fb7f09b40bc57b6262c010a155f Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Sun, 16 Sep 2018 23:05:36 +0200 Subject: [PATCH 1/3] fix(log): log lnd stderr output as errors Ensure that lnd output that goes to the stderr stream gets logged using the error log level and that the cause of the error is captured. --- app/lib/lnd/neutrino.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/lib/lnd/neutrino.js b/app/lib/lnd/neutrino.js index 68c60f50..4cf87fa0 100644 --- a/app/lib/lnd/neutrino.js +++ b/app/lib/lnd/neutrino.js @@ -114,10 +114,9 @@ class Neutrino extends EventEmitter { // Listen for when neutrino prints data to stderr. this.process.stderr.pipe(split2()).on('data', line => { if (process.env.NODE_ENV === 'development') { - const level = lndLogGetLevel(line) - lndLog[level](line) - if (level === 'error') { - this.lastError = line.split('[ERR] LTND:')[1] + lndLog.error(line) + if (line.startsWith('panic:')) { + this.lastError = line } } }) From 4e8225a709a1084f15d12cdf15ee4d42cd74a8a1 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Sun, 16 Sep 2018 23:19:47 +0200 Subject: [PATCH 2/3] fix(log): output logs in production mode Ensure that logs are output when the app is run in production mode. not only development mode so that its easier to diagnose an issue with a production build. --- app/lib/lnd/neutrino.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/app/lib/lnd/neutrino.js b/app/lib/lnd/neutrino.js index 4cf87fa0..6b6856e4 100644 --- a/app/lib/lnd/neutrino.js +++ b/app/lib/lnd/neutrino.js @@ -113,22 +113,18 @@ class Neutrino extends EventEmitter { // Listen for when neutrino prints data to stderr. this.process.stderr.pipe(split2()).on('data', line => { - if (process.env.NODE_ENV === 'development') { - lndLog.error(line) - if (line.startsWith('panic:')) { - this.lastError = line - } + lndLog.error(line) + if (line.startsWith('panic:')) { + this.lastError = line } }) // Listen for when neutrino prints data to stdout. this.process.stdout.pipe(split2()).on('data', line => { - if (process.env.NODE_ENV === 'development') { - const level = lndLogGetLevel(line) - lndLog[level](line) - if (level === 'error') { - this.lastError = line.split('[ERR] LTND:')[1] - } + const level = lndLogGetLevel(line) + lndLog[level](line) + if (level === 'error') { + this.lastError = line.split('[ERR] LTND:')[1] } // password RPC server listening (wallet unlocker started). From be2482ef4f107c47ade207b05b312a5a0d2b36d2 Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Sun, 16 Sep 2018 23:20:08 +0200 Subject: [PATCH 3/3] fix(log): only enable top level lnd logs limit the log namespaces that are enabled by default to only include the top level lnd namespace and not also all of it's sub-namespaces. --- app/lib/utils/log.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/lib/utils/log.js b/app/lib/utils/log.js index 1bb57f47..f9cf51d8 100644 --- a/app/lib/utils/log.js +++ b/app/lib/utils/log.js @@ -8,7 +8,7 @@ debugLogger.inspectOptions = { // Enable all zap logs if DEBUG has not been explicitly set. if (!process.env.DEBUG) { // debugLogger.debug.enable('zap:*') - process.env.DEBUG = 'zap:main,zap:lnd*,zap:updater' + process.env.DEBUG = 'zap:main,zap:lnd,zap:updater' } if (!process.env.DEBUG_LEVEL) { process.env.DEBUG_LEVEL = 'info' @@ -53,7 +53,7 @@ const logConfig = name => ({ // Create logs for use in the app. export const mainLog = debugLogger.config(logConfig('main'))('zap') -export const lndLog = debugLogger.config(logConfig('lnd '))('zap') +export const lndLog = debugLogger.config(logConfig('lnd'))('zap') export const updaterLog = debugLogger.config(logConfig('updater'))('zap') let lndLogLevel = null // stored most recent log level for continuity