Skip to content

Commit

Permalink
Fix. 修复file中object未能正确stringify的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
RavelloH committed Jan 18, 2025
1 parent d9b1c24 commit 03a75ca
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
20 changes: 15 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ class Toolkit {

return paddedLines.join("\n");
}

stringify(obj) {
if (typeof obj === "string") {
return obj;
}
if (typeof obj === "object") {
return JSON.stringify(obj, null, 2);
}
return obj.toString();
}
}

class Screen {
Expand Down Expand Up @@ -302,7 +312,7 @@ class File {
`[${
time || this.toolkit.formatTime()
}][INFO] ${this.toolkit.encryptPrivacyContent(
message,
this.toolkit.stringify(message),
this.config.blockedWordsList
)}`
);
Expand All @@ -312,7 +322,7 @@ class File {
`[${
time || this.toolkit.formatTime()
}][WARNING] ${this.toolkit.encryptPrivacyContent(
message,
this.toolkit.stringify(message),
this.config.blockedWordsList
)}`
);
Expand All @@ -322,7 +332,7 @@ class File {
`[${
time || this.toolkit.formatTime()
}][ERROR] ${this.toolkit.encryptPrivacyContent(
message,
this.toolkit.stringify(message),
this.config.blockedWordsList
)}`
);
Expand All @@ -332,7 +342,7 @@ class File {
`[${
time || this.toolkit.formatTime()
}][SUCCESS] ${this.toolkit.encryptPrivacyContent(
message,
this.toolkit.stringify(message),
this.config.blockedWordsList
)}`
);
Expand All @@ -342,7 +352,7 @@ class File {
`[${
time || this.toolkit.formatTime()
}][EXIT] ${this.toolkit.encryptPrivacyContent(
message,
this.toolkit.stringify(message),
this.config.blockedWordsList
)}`
);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rlog-js",
"version": "1.4.1",
"version": "1.4.2",
"description": "A module for optimizing log output in node.js, supporting colored output, embedded timestamp, log streaming writing, type coloring, keyword coloring, and so on.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 03a75ca

Please sign in to comment.