aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/createLoggerMiddleware.js
blob: 2707cbd9e239ab3c50e083055909d42761a3e0ea (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// log rpc activity
module.exports = createLoggerMiddleware

function createLoggerMiddleware ({ origin }) {
  return function loggerMiddleware (req, res, next, end) {
    next((cb) => {
      if (res.error) {
        log.error('Error in RPC response:\n', res)
      }
      if (req.isMetamaskInternal) return
      log.info(`RPC (${origin}):`, req, '->', res)
      cb()
    })
  }
}