mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
This reverts commit 1110287fe153bba44b8a7504611c2648b50e065f, reversing changes made to 72eb233ee953c381407f0121f76822a79753e4ee.
22 lines
616 B
JavaScript
22 lines
616 B
JavaScript
const log = require('loglevel')
|
|
|
|
module.exports = createLoggerMiddleware
|
|
|
|
/**
|
|
* Returns a middleware that logs RPC activity
|
|
* @param {{ origin: string }} opts - The middleware options
|
|
* @returns {Function}
|
|
*/
|
|
function createLoggerMiddleware (opts) {
|
|
return function loggerMiddleware (/** @type {any} */ req, /** @type {any} */ res, /** @type {Function} */ next) {
|
|
next((/** @type {Function} */ cb) => {
|
|
if (res.error) {
|
|
log.error('Error in RPC response:\n', res)
|
|
}
|
|
if (req.isMetamaskInternal) return
|
|
log.info(`RPC (${opts.origin}):`, req, '->', res)
|
|
cb()
|
|
})
|
|
}
|
|
}
|