Welcome to mirror list, hosted at ThFree Co, Russian Federation.

proc-log-listener.js « utils « lib - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2cfe94ecb0cf246607b0997024ad05e2d4c1413a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const log = require('npmlog')
const { inspect } = require('util')
module.exports = () => {
  process.on('log', (level, ...args) => {
    try {
      log[level](...args)
    } catch (ex) {
      try {
        // if it crashed once, it might again!
        log.verbose(`attempt to log ${inspect([level, ...args])} crashed`, ex)
      } catch (ex2) {
        console.error(`attempt to log ${inspect([level, ...args])} crashed`, ex)
      }
    }
  })
}

// for tests
/* istanbul ignore next */
module.exports.reset = () => {
  process.removeAllListeners('log')
}