Fix style issue of logger.js

This commit is contained in:
Tyler Long
2017-04-11 23:46:11 +08:00
parent e91229f69f
commit dc4edf775d
2 changed files with 26 additions and 21 deletions

View File

@@ -42,7 +42,9 @@
"ignore": [ "ignore": [
"**/parser/*.js", "**/parser/*.js",
"src/d3.js", "src/d3.js",
"dist/*.js" "dist/**/*.js",
"docs/**/*.js",
"editor/**/*.js"
] ]
}, },
"dependencies": { "dependencies": {

View File

@@ -10,16 +10,16 @@
* => [2011-3-3T20:24:4.810 error (5021)] booom * => [2011-3-3T20:24:4.810 error (5021)] booom
*/ */
const LEVELS = { // const LEVELS = {
debug: 1, // debug: 1,
info: 2, // info: 2,
warn: 3, // warn: 3,
error: 4, // error: 4,
fatal: 5, // fatal: 5,
default: 5 // default: 5
} // }
var defaultLevel = LEVELS.error // var defaultLevel = LEVELS.error
// exports.setLogLevel = function (level) { // exports.setLogLevel = function (level) {
// defaultLevel = level; // defaultLevel = level;
@@ -73,17 +73,20 @@ var fatal = function () {}
* * fatal: 5 * * fatal: 5
*/ */
exports.setLogLevel = function (level) { exports.setLogLevel = function (level) {
switch (level) { if (level < 6) {
case 1: exports.Log.fatal = window.console.debug.bind(window.console, format('FATAL'), 'color:grey;', 'color: red;')
exports.Log.debug = window.console.debug.bind(window.console, format('DEBUG', name), 'color:grey;', 'color: green;') }
case 2: if (level < 5) {
exports.Log.info = window.console.debug.bind(window.console, format('INFO', name), 'color:grey;', 'color: info;') exports.Log.error = window.console.debug.bind(window.console, format('ERROR'), 'color:grey;', 'color: red;')
case 3: }
exports.Log.warn = window.console.debug.bind(window.console, format('INFO', name), 'color:grey;', 'color: orange;') if (level < 4) {
case 4: exports.Log.warn = window.console.debug.bind(window.console, format('WARN'), 'color:grey;', 'color: orange;')
exports.Log.error = window.console.debug.bind(window.console, format('ERROR', name), 'color:grey;', 'color: red;') }
case 5: if (level < 3) {
exports.Log.fatal = window.console.debug.bind(window.console, format('FATAL', name), 'color:grey;', 'color: red;') exports.Log.info = window.console.debug.bind(window.console, format('INFO'), 'color:grey;', 'color: info;')
}
if (level < 2) {
exports.Log.debug = window.console.debug.bind(window.console, format('DEBUG'), 'color:grey;', 'color: green;')
} }
} }