@magic/log
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "@magic/log", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "enhanced console.log", | ||
@@ -24,6 +24,6 @@ "main": "src/index.js", | ||
"devDependencies": { | ||
"@magic/test": "github:magic/test" | ||
"@magic/test": "0.0.2" | ||
}, | ||
"dependencies": { | ||
"@magic/types": "0.0.1" | ||
"@magic/types": "0.0.2" | ||
}, | ||
@@ -30,0 +30,0 @@ "files": [ |
@@ -8,7 +8,17 @@ const is = require('@magic/types') | ||
log.resetLevel = () => (process.env.NODE_ENV === 'production' ? 1 : 0) | ||
log.resetLevel = (env = process.env.NODE_ENV) => { | ||
if (env === 'production') { | ||
log.level = 1 | ||
} else { | ||
log.level = 0 | ||
} | ||
return log.level | ||
} | ||
log.getLevel = () => (is.number(log.level) ? log.level : log.resetLevel()) | ||
log.setLevel = lvl => { | ||
log.setLevel = (lvl, env = process.env.NODE_ENV) => { | ||
if (is.undefinedOrNull(lvl)) { | ||
return log.resetLevel() | ||
} | ||
if (is.string(lvl)) { | ||
@@ -18,8 +28,15 @@ lvl = log.levels.indexOf(lvl) | ||
if (!is.number(lvl)) { | ||
lvl = process.env.NODE_ENV === 'production' ? 1 : 0 | ||
if (!is.number(lvl) || lvl < 0) { | ||
if (env === 'production') { | ||
lvl = 1 | ||
} else { | ||
lvl = 0 | ||
} | ||
} | ||
log.level = Math.min(log.levels.length - 1, Math.max(0, lvl)) | ||
if (lvl > log.levels.length - 1) { | ||
lvl = log.levels.length - 1 | ||
} | ||
log.level = lvl | ||
return log.level | ||
@@ -68,7 +85,6 @@ } | ||
log.time = (a) => { | ||
log.time = a => { | ||
if (log.getLevel() > 1) { | ||
return false | ||
} | ||
console.time(a) | ||
@@ -78,3 +94,3 @@ return true | ||
log.timeEnd = (a) => { | ||
log.timeEnd = a => { | ||
if (log.getLevel() > 1) { | ||
@@ -81,0 +97,0 @@ return false |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
41224
192
+ Added@magic/types@0.0.2(transitive)
- Removed@magic/types@0.0.1(transitive)
Updated@magic/types@0.0.2