aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/createLoggerMiddleware.js
blob: b92a965de09997307dc779846233e7c2b9b5e34f (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()
    })
  }
}