mirror of
https://github.com/seejohnrun/haste-server.git
synced 2024-11-01 03:21:21 +00:00
Logger configuration
This commit is contained in:
parent
a6bd69f20a
commit
0fe0306caa
2 changed files with 22 additions and 4 deletions
10
config.js
10
config.js
|
@ -3,6 +3,14 @@
|
||||||
"host": "localhost",
|
"host": "localhost",
|
||||||
"port": 7777,
|
"port": 7777,
|
||||||
|
|
||||||
"keyLength": 6
|
"keyLength": 6,
|
||||||
|
|
||||||
|
"logging": [
|
||||||
|
{
|
||||||
|
"level": "verbose",
|
||||||
|
"type": "Console",
|
||||||
|
"colorize": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
14
server.js
14
server.js
|
@ -12,9 +12,19 @@ var config = JSON.parse(fs.readFileSync('config.js', 'utf8'));
|
||||||
config.port = config.port || 7777;
|
config.port = config.port || 7777;
|
||||||
config.host = config.host || 'localhost';
|
config.host = config.host || 'localhost';
|
||||||
|
|
||||||
// Configure logging - TODO make configurable
|
// Set up the logger
|
||||||
|
if (config.logging) {
|
||||||
|
try {
|
||||||
winston.remove(winston.transports.Console);
|
winston.remove(winston.transports.Console);
|
||||||
winston.add(winston.transports.Console, { colorize: true, level: 'verbose' });
|
} 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 preparse static instead of using exists
|
||||||
// TODO implement command line
|
// TODO implement command line
|
||||||
|
|
Loading…
Reference in a new issue