electron-ipc-log
Log all user-defined IPC traffic in an electron app.
Install
npm install electron-ipc-log
Usage
var electronIpcLog =
API
electronIpcLog(log: function)
Accepts a logging function with parameters (event: object)
, where event is an object { channel:string, data:object, sent:bool, sync:bool }
.
channel
- name of the channel the message was sent through.data
- any number of arguments passed by the user via IPC.sent
- true if sent viaipcRenderer.send
oripcRenderer.sendSync
(ipcRenderer
only)sync
- true if synchronous (ipcRenderer
only)
Needs to be called once per process, so for example if you have one main process and two renderer windows, and you want to log IPC traffic in each process, you need to call electronIpcLog
in each process.
All internal electron IPC messages (prefixed with ELECTRON
or CHROME
, e.g. ELECTRON_BROWSER_REQUIRE
) are ignored, as they are very noisy and not useful for most use cases. I'm open to adding a config option for verbose logging if someone really needs it.
Note: this module monkey patches the emit
, send
, and sendSync
methods of ipcRender
(or just ipcMain.emit
depending on the context). It's not ideal but I don't know of another way of hooking into electron IPC events at this time. This is the method devtron
uses.
Contributing
Contributions welcome! Please read the contributing guidelines first.