From c2b0df6d2e68a2bce863b03b619f50d75259acea Mon Sep 17 00:00:00 2001 From: DrJume Date: Sun, 2 Sep 2018 23:22:35 +0200 Subject: [PATCH] Enhance logging - debug log enabled by default --- helpers/read-config.js | 2 +- lib/VplanParser.js | 3 ++- routes/api.js | 2 +- services/UploadWatcher.js | 11 ++++++++--- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/helpers/read-config.js b/helpers/read-config.js index 25c346d..2812996 100644 --- a/helpers/read-config.js +++ b/helpers/read-config.js @@ -5,7 +5,7 @@ const { recursiveObjPatch } = require('util/object-tools') const DefaultConfig = { webserver: { port: 8000, log_debug_tty: false, log_file: false }, updater: { pre_release: false }, - dev: { silence_debug_log: true }, + dev: { silence_debug_log: false }, } module.exports = async function readConfig(configPath) { diff --git a/lib/VplanParser.js b/lib/VplanParser.js index 4a2f0bd..7fabc08 100644 --- a/lib/VplanParser.js +++ b/lib/VplanParser.js @@ -142,7 +142,8 @@ const VplanParser = { return undefined } - log.info('DETECTING_QUEUEDAY_BY_DATE_CALC') + log.info('AUTO_SCHEDULING', `${transformedVplanJSObj.type}: [${queueDateString}]`) + log.debug('QUEUEDAY_BY_DATE_CALC') const today = moment() log.debug('QUEUEDATE', queueDate) diff --git a/routes/api.js b/routes/api.js index 708f66d..b5576ad 100644 --- a/routes/api.js +++ b/routes/api.js @@ -19,7 +19,7 @@ async function readVplan(queueDay, vplanType) { ) if (err) { if (err.code === 'ENOENT') { - log.warn('NO_VPLAN_AVAILABLE', `${queueDay}/${vplanType}`) + log.debug('NO_VPLAN_AVAILABLE', `${queueDay}/${vplanType}`) } else { log.err('FILE_READ_ERR', err) } diff --git a/services/UploadWatcher.js b/services/UploadWatcher.js index a7ff333..b83e26f 100644 --- a/services/UploadWatcher.js +++ b/services/UploadWatcher.js @@ -55,6 +55,11 @@ module.exports = async function UploadWatcher(callback) { } } }) + .on('change', async (filePath) => { + if (path.extname(filePath) === '.json') { + log.info('VPLAN_FILE_UPDATED', filePath) + } + }) .on('add', async (filePath) => { log.debug('FILE_DETECTED', filePath) @@ -69,7 +74,7 @@ module.exports = async function UploadWatcher(callback) { return } - log.info('USING_JSON_FILE', filePath) + log.info('VPLAN_FILE_LOADED', filePath) return } @@ -97,8 +102,8 @@ module.exports = async function UploadWatcher(callback) { // manual upload if (['current', 'next'].includes(uploadLocation)) { - log.info('MANUAL_UPLOAD') - log.info('DETECTING_QUEUEDAY_BY_UPLOAD_DIR') + log.info('MANUAL_SCHEDULING', `${transformedVplanData.type}: [${transformedVplanData.head.title.trim()}]`) + log.debug('QUEUEDAY_BY_UPLOAD_DIR') callback(uploadLocation, transformedVplanData, vplanType) return