diff --git a/_config.yml b/_config.yml index 58e3247..4e816a0 100644 --- a/_config.yml +++ b/_config.yml @@ -29,3 +29,6 @@ mqtt: # Port number to listen on port: 8080 + +# Log level for Winston's file transports (set to `error` to reduce logging to a minimum) +# winston_file_log_level: error diff --git a/server.js b/server.js index ca8d43b..f748d42 100644 --- a/server.js +++ b/server.js @@ -34,6 +34,7 @@ var CONFIG_DIR = process.env.CONFIG_DIR || process.cwd(), // The topic type to send state changes to smartthings TOPIC_WRITE_STATE = 'set_state', SUFFIX_WRITE_STATE = 'state_write_suffix', + WINSTON_FILE_LOG_LEVEL = 'winston_file_log_level', RETAIN = 'retain'; var app = express(), @@ -137,6 +138,11 @@ function migrateState (version) { config.port = 8080; } + // Default file transport logging level + if (!config[WINSTON_FILE_LOG_LEVEL]) { + config[WINSTON_FILE_LOG_LEVEL] = 'info'; + } + // Default protocol if (!url.parse(config.mqtt.host).protocol) { config.mqtt.host = 'mqtt://' + config.mqtt.host; @@ -323,6 +329,8 @@ async.series([ winston.info('Perfoming configuration migration'); migrateState(state.version); + winston.default.transports.file.level = config[WINSTON_FILE_LOG_LEVEL]; + process.nextTick(next); }, function connectToMQTT (next) {