@things-factory/env 5.0.0-alpha.38 → 5.0.0-alpha.40

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 +8 -1
  2. package/package.json +2 -2
package/lib/logger.js CHANGED
@@ -1,4 +1,5 @@
1
1
  const Raygun = require('./winston-raygun')
2
+ const moment = require('moment-timezone')
2
3
 
3
4
  var config = require('./config')
4
5
  var { createLogger, format, transports } = require('winston')
@@ -38,11 +39,17 @@ if (RaygunApiKey) {
38
39
  )
39
40
  }
40
41
 
42
+ const SYSTEM_TZ = Intl.DateTimeFormat().resolvedOptions().timeZone
43
+ const systemTimestamp = format((info, opts) => {
44
+ if (opts.tz) info.timestamp = moment().tz(opts.tz).format()
45
+ return info
46
+ })
47
+
41
48
  const logFormat = printf(({ level, message, timestamp }) => {
42
49
  return `${timestamp} ${level}: ${message}`
43
50
  })
44
51
 
45
52
  module.exports = createLogger({
46
- format: combine(timestamp(), splat(), logFormat),
53
+ format: combine(systemTimestamp({ tz: SYSTEM_TZ }), splat(), logFormat),
47
54
  transports: logTransports
48
55
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/env",
3
- "version": "5.0.0-alpha.38",
3
+ "version": "5.0.0-alpha.40",
4
4
  "description": "Things Factory running environment helper library",
5
5
  "main": "index.js",
6
6
  "author": "heartyoh@hatiolab.com",
@@ -27,5 +27,5 @@
27
27
  "winston": "^3.2.1",
28
28
  "winston-daily-rotate-file": "^4.2.1"
29
29
  },
30
- "gitHead": "b5e6badbf7bfb3e509c5d065da635da7c084ffce"
30
+ "gitHead": "c64462e85c9b744250f5649d28c0ec4bd56a1b38"
31
31
  }