@tryghost/pretty-stream 0.1.28 → 0.2.0

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.
Files changed (2) hide show
  1. package/lib/PrettyStream.js +16 -10
  2. package/package.json +7 -3
@@ -101,17 +101,23 @@ class PrettyStream extends Transform {
101
101
 
102
102
  let output = '';
103
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
- }
104
+ // Handle time formatting
105
+ let time;
113
106
 
114
- const time = dateFormat.asString('yyyy-MM-dd hh:mm:ss', dataTime);
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.28",
4
- "repository": "https://github.com/TryGhost/framework/tree/main/packages/pretty-stream",
3
+ "version": "0.2.0",
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",
@@ -29,5 +33,5 @@
29
33
  "lodash": "^4.17.21",
30
34
  "prettyjson": "^1.2.5"
31
35
  },
32
- "gitHead": "b169bd1734b749c3abdaac134f030756b9a282bb"
36
+ "gitHead": "e395f1d79edee4aecc36e572bb402016a8ba9273"
33
37
  }