Skip to content

Commit 9fd1893

Browse files
Adding the ability to configure Winston's file transport logging level.
1 parent 066d3f4 commit 9fd1893

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

_config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ mqtt:
2424

2525
# Port number to listen on
2626
port: 8080
27+
28+
# Log level for Winston's file transports (set to `error` to reduce logging to a minimum)
29+
# winston_file_log_level: error

server.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var CONFIG_DIR = process.env.CONFIG_DIR || process.cwd(),
3434
// The topic type to send state changes to smartthings
3535
TOPIC_WRITE_STATE = 'set_state',
3636
SUFFIX_WRITE_STATE = 'state_write_suffix',
37+
WINSTON_FILE_LOG_LEVEL = 'winston_file_log_level',
3738
RETAIN = 'retain';
3839

3940
var app = express(),
@@ -137,6 +138,11 @@ function migrateState (version) {
137138
config.port = 8080;
138139
}
139140

141+
// Default file transport logging level
142+
if (!config[WINSTON_FILE_LOG_LEVEL]) {
143+
config[WINSTON_FILE_LOG_LEVEL] = 'info';
144+
}
145+
140146
// Default protocol
141147
if (!url.parse(config.mqtt.host).protocol) {
142148
config.mqtt.host = 'mqtt://' + config.mqtt.host;
@@ -323,6 +329,8 @@ async.series([
323329
winston.info('Perfoming configuration migration');
324330
migrateState(state.version);
325331

332+
winston.default.transports.file.level = config[WINSTON_FILE_LOG_LEVEL];
333+
326334
process.nextTick(next);
327335
},
328336
function connectToMQTT (next) {

0 commit comments

Comments
 (0)