mirror of
https://github.com/toptal/haste-server.git
synced 2024-11-12 10:23:57 +01:00
Logger configuration
This commit is contained in:
parent
a6bd69f20a
commit
0fe0306caa
10
config.js
10
config.js
@ -3,6 +3,14 @@
|
||||
"host": "localhost",
|
||||
"port": 7777,
|
||||
|
||||
"keyLength": 6
|
||||
"keyLength": 6,
|
||||
|
||||
"logging": [
|
||||
{
|
||||
"level": "verbose",
|
||||
"type": "Console",
|
||||
"colorize": true
|
||||
}
|
||||
]
|
||||
|
||||
}
|
||||
|
16
server.js
16
server.js
@ -12,9 +12,19 @@ var config = JSON.parse(fs.readFileSync('config.js', 'utf8'));
|
||||
config.port = config.port || 7777;
|
||||
config.host = config.host || 'localhost';
|
||||
|
||||
// Configure logging - TODO make configurable
|
||||
winston.remove(winston.transports.Console);
|
||||
winston.add(winston.transports.Console, { colorize: true, level: 'verbose' });
|
||||
// Set up the logger
|
||||
if (config.logging) {
|
||||
try {
|
||||
winston.remove(winston.transports.Console);
|
||||
} catch(er) { }
|
||||
var detail, type;
|
||||
for (var i = 0; i < config.logging.length; i++) {
|
||||
detail = config.logging[i];
|
||||
type = detail.type;
|
||||
delete detail.type;
|
||||
winston.add(winston.transports[type], detail);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO preparse static instead of using exists
|
||||
// TODO implement command line
|
||||
|
Loading…
Reference in New Issue
Block a user