@tryghost/pretty-stream 0.1.29 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/PrettyStream.js +16 -10
- package/package.json +9 -6
package/LICENSE
CHANGED
package/README.md
CHANGED
package/lib/PrettyStream.js
CHANGED
|
@@ -101,17 +101,23 @@ class PrettyStream extends Transform {
|
|
|
101
101
|
|
|
102
102
|
let output = '';
|
|
103
103
|
|
|
104
|
-
//
|
|
105
|
-
|
|
106
|
-
const dataTime = new Date(data.time || now);
|
|
107
|
-
|
|
108
|
-
// If the timezone offset is equal to the current timezone offset, and that timezone offset is not 0,
|
|
109
|
-
// then we need to adjust the time
|
|
110
|
-
if (dataTime.getTimezoneOffset() === now.getTimezoneOffset() && dataTime.getTimezoneOffset() !== 0) {
|
|
111
|
-
dataTime.setMinutes(dataTime.getMinutes() + dataTime.getTimezoneOffset());
|
|
112
|
-
}
|
|
104
|
+
// Handle time formatting
|
|
105
|
+
let time;
|
|
113
106
|
|
|
114
|
-
|
|
107
|
+
if (data.time) {
|
|
108
|
+
// If time is provided as a string in the expected format, use it directly
|
|
109
|
+
if (typeof data.time === 'string' && /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(data.time)) {
|
|
110
|
+
time = data.time;
|
|
111
|
+
} else {
|
|
112
|
+
// Otherwise, parse and format it
|
|
113
|
+
const dataTime = new Date(data.time);
|
|
114
|
+
time = dateFormat.asString('yyyy-MM-dd hh:mm:ss', dataTime);
|
|
115
|
+
}
|
|
116
|
+
} else {
|
|
117
|
+
// No time provided, use current time
|
|
118
|
+
const now = new Date();
|
|
119
|
+
time = dateFormat.asString('yyyy-MM-dd hh:mm:ss', now);
|
|
120
|
+
}
|
|
115
121
|
|
|
116
122
|
let logLevel = _private.levelFromName[data.level].toUpperCase();
|
|
117
123
|
const codes = _private.colors[_private.colorForLevel[data.level]];
|
package/package.json
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/pretty-stream",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"repository":
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/TryGhost/framework.git",
|
|
7
|
+
"directory": "packages/pretty-stream"
|
|
8
|
+
},
|
|
5
9
|
"author": "Ghost Foundation",
|
|
6
10
|
"license": "MIT",
|
|
7
11
|
"main": "index.js",
|
|
@@ -20,14 +24,13 @@
|
|
|
20
24
|
},
|
|
21
25
|
"devDependencies": {
|
|
22
26
|
"c8": "10.1.3",
|
|
23
|
-
"mocha": "
|
|
27
|
+
"mocha": "11.7.5",
|
|
24
28
|
"should": "13.2.3",
|
|
25
|
-
"sinon": "
|
|
29
|
+
"sinon": "21.0.1"
|
|
26
30
|
},
|
|
27
31
|
"dependencies": {
|
|
28
32
|
"date-format": "^4.0.14",
|
|
29
33
|
"lodash": "^4.17.21",
|
|
30
34
|
"prettyjson": "^1.2.5"
|
|
31
|
-
}
|
|
32
|
-
"gitHead": "783b40c3ece6e1c9e293d09f2c069baa3e1110b2"
|
|
35
|
+
}
|
|
33
36
|
}
|