Better logging with winston

This commit is contained in:
Florent Vilmart
2016-03-26 13:47:44 -04:00
parent d47a756f80
commit 5c1fe3a325
15 changed files with 180 additions and 255 deletions

View File

@@ -1,41 +1,5 @@
let LogLevel = {
'VERBOSE': 0,
'DEBUG': 1,
'INFO': 2,
'ERROR': 3,
'NONE': 4
}
import { addGroup } from '../logger';
function getCurrentLogLevel() {
if (PLog.logLevel && PLog.logLevel in LogLevel) {
return LogLevel[PLog.logLevel];
}
return LogLevel['ERROR'];
}
function verbose(): void {
if (getCurrentLogLevel() <= LogLevel['VERBOSE']) {
console.log.apply(console, arguments)
}
}
function log(): void {
if (getCurrentLogLevel() <= LogLevel['INFO']) {
console.log.apply(console, arguments)
}
}
function error(): void {
if (getCurrentLogLevel() <= LogLevel['ERROR']) {
console.error.apply(console, arguments)
}
}
let PLog = {
log: log,
error: error,
verbose: verbose,
logLevel: 'INFO'
};
let PLog = addGroup('parse-live-query-server');
module.exports = PLog;

View File

@@ -26,8 +26,7 @@ class ParseLiveQueryServer {
config = config || {};
// Set LogLevel
PLog.logLevel = config.logLevel || 'INFO';
PLog.level = config.logLevel || 'INFO';
// Store keys, convert obj to map
let keyPairs = config.keyPairs || {};
this.keyPairs = new Map();