hubot 13.1.2 → 13.1.4
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 +2 -2
- package/src/adapters/Shell.mjs +19 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hubot",
|
|
3
|
-
"version": "13.1.
|
|
3
|
+
"version": "13.1.4",
|
|
4
4
|
"author": "hubot",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"github",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"start": "bin/hubot",
|
|
30
30
|
"gen": "bin/hubot --create myhubot",
|
|
31
31
|
"pretest": "standard",
|
|
32
|
-
"test": "node --test --test-timeout=
|
|
32
|
+
"test": "node --test --test-timeout=40000",
|
|
33
33
|
"test:smoke": "node src/**/*.js",
|
|
34
34
|
"test:e2e": "bin/e2e-test.sh",
|
|
35
35
|
"build:local": "npx @hubot-friends/sfab --folder ./docs --destination ./_site --verbose --serve /hubot/ --watch-path ./docs --scripts ./sfab-hooks",
|
package/src/adapters/Shell.mjs
CHANGED
|
@@ -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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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', () => {
|