hubot 13.1.2 → 13.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hubot",
3
- "version": "13.1.2",
3
+ "version": "13.1.3",
4
4
  "author": "hubot",
5
5
  "keywords": [
6
6
  "github",
@@ -39,11 +39,26 @@ class Shell extends Adapter {
39
39
  super(robot)
40
40
  this.name = 'Shell'
41
41
  const levels = ['trace', 'debug', 'info', 'warn', 'error', 'fatal']
42
+ const logLevel = process.env.HUBOT_LOG_LEVEL || 'info'
43
+ const levelPriorities = levels.reduce((acc, current, idx) => {
44
+ acc[current] = idx
45
+ return acc
46
+ }, {})
47
+
48
+ const configuredPriority = levelPriorities[logLevel]
49
+
50
+ const noop = async () => {}
51
+
42
52
  levels.forEach(level => {
43
- robot.logger[level] = async (...args) => {
44
- const color = levelColors[level] || ''
45
- const msg = `${color}[${level}]${reset} ${args.map(a => typeof a === 'object' ? JSON.stringify(a) : a).join(' ')}`
46
- await this.send({ user: { name: 'Logger', room: 'Shell' } }, msg)
53
+ const priority = levelPriorities[level]
54
+ if (priority >= configuredPriority) {
55
+ robot.logger[level] = async (...args) => {
56
+ const color = levelColors[level] || ''
57
+ const msg = `${color}[${level}]${reset} ${args.map(a => typeof a === 'object' ? JSON.stringify(a) : a).join(' ')}`
58
+ await this.send({ user: { name: 'Logger', room: 'Shell' } }, msg)
59
+ }
60
+ } else {
61
+ robot.logger[level] = noop
47
62
  }
48
63
  })
49
64
  this.robot.on('scripts have loaded', () => {