@things-factory/env 5.0.0-alpha.21 → 5.0.0-alpha.24

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/lib/logger.js CHANGED
@@ -1,3 +1,5 @@
1
+ const Raygun = require('./winston-raygun')
2
+
1
3
  var config = require('./config')
2
4
  var { createLogger, format, transports } = require('winston')
3
5
  require('winston-daily-rotate-file')
@@ -5,6 +7,7 @@ require('winston-daily-rotate-file')
5
7
  const { combine, timestamp, splat, simple, printf } = format
6
8
 
7
9
  var { file: fileConfig, console: consoleConfig } = config.get('logger', {})
10
+ var { apiKey: RaygunApiKey } = config.get('raygun', {})
8
11
 
9
12
  var logTransports = []
10
13
 
@@ -27,6 +30,14 @@ if (consoleConfig) {
27
30
  logTransports.push(new transports.Console(Object.assign({}, CONSOLE_LOGGER_CONFIG, consoleConfig)))
28
31
  }
29
32
 
33
+ if (RaygunApiKey) {
34
+ logTransports.push(
35
+ new Raygun({
36
+ apiKey: RaygunApiKey
37
+ })
38
+ )
39
+ }
40
+
30
41
  const logFormat = printf(({ level, message, timestamp }) => {
31
42
  return `${timestamp} ${level}: ${message}`
32
43
  })
@@ -0,0 +1,26 @@
1
+ const Transport = require('winston-transport')
2
+ const raygun = require('raygun')
3
+
4
+ module.exports = class Raygun extends Transport {
5
+ constructor(opts) {
6
+ super(opts)
7
+
8
+ var opts = opts || {}
9
+ this.name = 'raygun'
10
+ this.apiKey = opts.apiKey
11
+
12
+ this.raygunClient = opts.raygunClient || new raygun.Client().init({ apiKey: this.apiKey })
13
+ }
14
+
15
+ log(info, callback) {
16
+ setImmediate(() => {
17
+ this.emit('logged', info)
18
+ })
19
+
20
+ if (info.level === 'error') {
21
+ return this.raygunClient.send(info)
22
+ }
23
+
24
+ callback()
25
+ }
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/env",
3
- "version": "5.0.0-alpha.21",
3
+ "version": "5.0.0-alpha.24",
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
+ "raygun": "^0.13.2",
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": "4bce1f9b142a4a1d1c786a67415401c96c44eb89"
30
+ "gitHead": "077d90d32fa548afd4925ce07f8f7f27c6b3399a"
30
31
  }