@tryghost/pretty-stream 0.1.27 → 0.1.29

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2013-2023 Ghost Foundation
3
+ Copyright (c) 2013-2025 Ghost Foundation
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -37,4 +37,4 @@ Follow the instructions for the top-level repo.
37
37
 
38
38
  # Copyright & License
39
39
 
40
- Copyright (c) 2013-2023 Ghost Foundation - Released under the [MIT license](LICENSE).
40
+ Copyright (c) 2013-2025 Ghost Foundation - Released under the [MIT license](LICENSE).
@@ -1,14 +1,15 @@
1
- const moment = require('moment');
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
- const isString = require('lodash/isString');
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 (!isString(data)) {
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
- const time = moment(data.time).format('YYYY-MM-DD HH:mm:ss');
103
+
104
+ // Convert the time to UTC
105
+ const now = new Date();
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
+ }
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(omit(data, ['time', 'level', 'name', 'hostname', 'pid', 'v', 'msg']), function (value, key) {
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.27",
3
+ "version": "0.1.29",
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.2",
23
- "mocha": "10.7.0",
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": "d86b1d4fb719b9fb3535a31576c06e42ad1d8476"
32
+ "gitHead": "783b40c3ece6e1c9e293d09f2c069baa3e1110b2"
33
33
  }