mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-24 11:01:41 +01:00
18 lines
417 B
JavaScript
18 lines
417 B
JavaScript
const log = require('loglevel')
|
|
|
|
// 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()
|
|
})
|
|
}
|
|
}
|