Skip to content

Commit 248f937

Browse files
committed
修正e.data 的记录
1 parent abc07f9 commit 248f937

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@open-node/logger",
3-
"version": "0.3.2",
3+
"version": "0.3.3",
44
"description": "log recorder, info and error",
55
"main": "src/logger.js",
66
"scripts": {

‎src/logger.js‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function Logger({ errorLogPath, infoLogPath }) {
2626
const code = e.code || "unknown";
2727
const file = `${errorLogPath}/${code}.err`;
2828
const content = [now(), e.message];
29+
if (e.data) content.push(JSON.stringify(e.data));
2930
if (extra != null) content.push(JSON.stringify(extra));
3031
if (e.stack) content.push(JSON.stringify(e.stack));
3132
fs.appendFileSync(file, `${content.join("\t")}\n`);
@@ -77,9 +78,8 @@ function Logger({ errorLogPath, infoLogPath }) {
7778
const startedAt = Date.now();
7879
const res = await fn(...args);
7980
info(
80-
`Completed: ${name}\t${callId}\t${Date.now() - startedAt}ms\t${JSON.stringify(
81-
transform(res)
82-
)}`
81+
`Completed: ${name}\t${callId}\t${Date.now() -
82+
startedAt}ms\t${JSON.stringify(transform(res))}`
8383
);
8484
return res;
8585
} catch (e) {
@@ -94,7 +94,10 @@ function Logger({ errorLogPath, infoLogPath }) {
9494
info(`Begin: ${name}\t${callId}\t${argsHandler(args)}`);
9595
const startedAt = Date.now();
9696
const res = fn(...args);
97-
info(`Completed: ${name}\t${callId}\t${Date.now() - startedAt}ms\t${JSON.stringify(res)}`);
97+
info(
98+
`Completed: ${name}\t${callId}\t${Date.now() -
99+
startedAt}ms\t${JSON.stringify(res)}`
100+
);
98101
return res;
99102
} catch (e) {
100103
info(`Error: ${name}\t${callId}\t${e.message}`, e.stack);

0 commit comments

Comments
 (0)