@things-factory/env 4.3.0-alpha.0 → 4.4.0-alpha.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/logger.js +9 -1
  2. package/package.json +3 -2
package/lib/logger.js CHANGED
@@ -1,3 +1,5 @@
1
+ const moment = require('moment-timezone')
2
+
1
3
  var config = require('./config')
2
4
  var { createLogger, format, transports } = require('winston')
3
5
  require('winston-daily-rotate-file')
@@ -27,11 +29,17 @@ if (consoleConfig) {
27
29
  logTransports.push(new transports.Console(Object.assign({}, CONSOLE_LOGGER_CONFIG, consoleConfig)))
28
30
  }
29
31
 
32
+ const SYSTEM_TZ = Intl.DateTimeFormat().resolvedOptions().timeZone
33
+ const systemTimestamp = format((info, opts) => {
34
+ if (opts.tz) info.timestamp = moment().tz(opts.tz).format()
35
+ return info
36
+ })
37
+
30
38
  const logFormat = printf(({ level, message, timestamp }) => {
31
39
  return `${timestamp} ${level}: ${message}`
32
40
  })
33
41
 
34
42
  module.exports = createLogger({
35
- format: combine(timestamp(), splat(), logFormat),
43
+ format: combine(systemTimestamp({ tz: SYSTEM_TZ }), splat(), logFormat),
36
44
  transports: logTransports
37
45
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/env",
3
- "version": "4.3.0-alpha.0",
3
+ "version": "4.4.0-alpha.0",
4
4
  "description": "Things Factory running environment helper library",
5
5
  "main": "index.js",
6
6
  "author": "heartyoh@hatiolab.com",
@@ -22,9 +22,10 @@
22
22
  "dependency-solver": "^1.0.6",
23
23
  "fs-extra": "^9.0.1",
24
24
  "loader-utils": "^1.2.3",
25
+ "moment-timezone": "^0.5.27",
25
26
  "schema-utils": "^1.0.0",
26
27
  "winston": "^3.2.1",
27
28
  "winston-daily-rotate-file": "^4.2.1"
28
29
  },
29
- "gitHead": "6467d1b2a5b2f8abb1bc3982e4651a5742ad4043"
30
+ "gitHead": "5972c622d8359263909c2a699c6f26978b937c8c"
30
31
  }