@tryghost/pretty-stream 0.1.27 → 0.1.28
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 +19 -6
- package/package.json +5 -5
package/LICENSE
CHANGED
package/README.md
CHANGED
package/lib/PrettyStream.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
const
|
|
1
|
+
const dateFormat = require('date-format');
|
|
2
2
|
const Transform = require('stream').Transform;
|
|
3
3
|
const format = require('util').format;
|
|
4
4
|
const prettyjson = require('prettyjson');
|
|
5
5
|
const each = require('lodash/each');
|
|
6
|
-
const omit = require('lodash/omit');
|
|
7
6
|
const get = require('lodash/get');
|
|
8
7
|
const isArray = require('lodash/isArray');
|
|
9
8
|
const isEmpty = require('lodash/isEmpty');
|
|
10
9
|
const isObject = require('lodash/isObject');
|
|
11
|
-
|
|
10
|
+
|
|
11
|
+
const OMITTED_KEYS = ['time', 'level', 'name', 'hostname', 'pid', 'v', 'msg'];
|
|
12
|
+
|
|
12
13
|
const _private = {
|
|
13
14
|
levelFromName: {
|
|
14
15
|
10: 'trace',
|
|
@@ -83,7 +84,7 @@ class PrettyStream extends Transform {
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
_transform(data, enc, cb) {
|
|
86
|
-
if (
|
|
87
|
+
if (typeof data !== 'string') {
|
|
87
88
|
data = data.toString();
|
|
88
89
|
}
|
|
89
90
|
|
|
@@ -99,7 +100,19 @@ class PrettyStream extends Transform {
|
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
let output = '';
|
|
102
|
-
|
|
103
|
+
|
|
104
|
+
// Convert the time to UTC
|
|
105
|
+
const now = new Date();
|
|
106
|
+
const dataTime = new Date(data.time);
|
|
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
|
+
}
|
|
113
|
+
|
|
114
|
+
const time = dateFormat.asString('yyyy-MM-dd hh:mm:ss', dataTime);
|
|
115
|
+
|
|
103
116
|
let logLevel = _private.levelFromName[data.level].toUpperCase();
|
|
104
117
|
const codes = _private.colors[_private.colorForLevel[data.level]];
|
|
105
118
|
let bodyPretty = '';
|
|
@@ -125,7 +138,7 @@ class PrettyStream extends Transform {
|
|
|
125
138
|
output += format('[%s] %s %s\n', time, logLevel, bodyPretty);
|
|
126
139
|
}
|
|
127
140
|
|
|
128
|
-
each(
|
|
141
|
+
each(Object.fromEntries(Object.entries(data).filter(([key]) => !OMITTED_KEYS.includes(key))), function (value, key) {
|
|
129
142
|
// we always output errors for now
|
|
130
143
|
if (isObject(value) && value.message && value.stack) {
|
|
131
144
|
let error = '\n';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/pretty-stream",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.28",
|
|
4
4
|
"repository": "https://github.com/TryGhost/framework/tree/main/packages/pretty-stream",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,15 +19,15 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"c8": "10.1.
|
|
23
|
-
"mocha": "10.7.
|
|
22
|
+
"c8": "10.1.3",
|
|
23
|
+
"mocha": "10.7.3",
|
|
24
24
|
"should": "13.2.3",
|
|
25
25
|
"sinon": "18.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"date-format": "^4.0.14",
|
|
28
29
|
"lodash": "^4.17.21",
|
|
29
|
-
"moment": "^2.29.1",
|
|
30
30
|
"prettyjson": "^1.2.5"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "b169bd1734b749c3abdaac134f030756b9a282bb"
|
|
33
33
|
}
|