aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/createLoggerMiddleware.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/lib/createLoggerMiddleware.js')
-rw-r--r--app/scripts/lib/createLoggerMiddleware.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/scripts/lib/createLoggerMiddleware.js b/app/scripts/lib/createLoggerMiddleware.js
new file mode 100644
index 000000000..b92a965de
--- /dev/null
+++ b/app/scripts/lib/createLoggerMiddleware.js
@@ -0,0 +1,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()
+ })
+ }
+} \ No newline at end of file