hubot 13.1.1 → 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.1",
3
+ "version": "13.1.3",
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",
32
+ "test": "node --test --test-timeout=20000",
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",
@@ -45,6 +45,6 @@
45
45
  "dependencies": {
46
46
  "express": "^5.1.0",
47
47
  "express-basic-auth": "^1.2.1",
48
- "pino": "^9.6.0"
48
+ "pino": "^9.12.0"
49
49
  }
50
50
  }
package/src/Robot.mjs CHANGED
@@ -501,8 +501,9 @@ class Robot {
501
501
  //
502
502
  // Returns nothing.
503
503
  async loadAdapter (adapterPath = null) {
504
- if (this.adapter) {
504
+ if (this.adapter && this.adapter.use) {
505
505
  this.adapter = await this.adapter.use(this)
506
+ this.adapterName = this.adapter.name ?? this.adapter.constructor.name
506
507
  return
507
508
  }
508
509
  this.logger.debug(`Loading adapter ${adapterPath ?? 'from npmjs:'} ${this.adapterName}`)
@@ -521,6 +522,8 @@ class Robot {
521
522
  this.logger.error(`Cannot load adapter ${adapterPath ?? '[no path set]'} ${this.adapterName} - ${error}`)
522
523
  throw error
523
524
  }
525
+
526
+ this.adapterName = this.adapter.name ?? this.adapter.constructor.name
524
527
  }
525
528
 
526
529
  async requireAdapterFrom (adapaterPath) {
@@ -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', () => {