@aspecto/logger
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -25,3 +25,9 @@ "use strict"; | ||
else | ||
logs.push(COLORS.dim + COLORS.bold + ` ${key}: ` + COLORS.reset + COLORS.dim + `${JSON.stringify(value, null, 4)}` + COLORS.reset); | ||
logs.push(COLORS.dim + | ||
COLORS.bold + | ||
` ${key}: ` + | ||
COLORS.reset + | ||
COLORS.dim + | ||
`${JSON.stringify(value, null, 4)}` + | ||
COLORS.reset); | ||
}); | ||
@@ -54,3 +60,4 @@ return logs; | ||
toLog.push(`${COLORS.dim}${new Date().toTimeString().split(' ')[0]}${COLORS.reset} ` + | ||
color + COLORS.bold + | ||
color + | ||
COLORS.bold + | ||
`[${level.toUpperCase()}]:`.padEnd(9) + | ||
@@ -57,0 +64,0 @@ COLORS.reset + |
@@ -19,4 +19,12 @@ "use strict"; | ||
appVersion: packageJson.version, | ||
hostname: os.hostname() | ||
hostname: os.hostname(), | ||
}; | ||
const trySerialize = (val) => { | ||
try { | ||
return serialize_error_1.serializeError(val); | ||
} | ||
catch (_a) { | ||
return val; | ||
} | ||
}; | ||
const productionLogger = (level, outputAs, message, extra) => { | ||
@@ -28,6 +36,6 @@ if (level === types_1.LogLevel.Debug || level === types_1.LogLevel.Trace) | ||
message, | ||
metadata | ||
metadata, | ||
}; | ||
if (extra instanceof Error) { | ||
log.error = serialize_error_1.serializeError(extra); | ||
log.error = trySerialize(extra); | ||
} | ||
@@ -37,3 +45,3 @@ else if (extra) { | ||
if (value instanceof Error) { | ||
log.error = serialize_error_1.serializeError(value); | ||
log.error = trySerialize(value); | ||
delete extra[key]; | ||
@@ -40,0 +48,0 @@ } |
{ | ||
"name": "@aspecto/logger", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "", | ||
@@ -34,7 +34,2 @@ "main": "dist/index.js", | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "yarn build && git add ." | ||
} | ||
}, | ||
"jest": { | ||
@@ -41,0 +36,0 @@ "preset": "ts-jest", |
@@ -6,5 +6,4 @@ # Aspecto logger | ||
#### Install via NPM | ||
Add to package json: | ||
``` | ||
"@aspecto/logger": "0.0.1" | ||
yarn add @aspecto/logger | ||
``` | ||
@@ -20,2 +19,2 @@ | ||
const logger = require('@aspecto/logger').default; | ||
``` | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
12806
203