3.0.1 • Published 7 years ago

electron-ipc-log v3.0.1

Weekly downloads
31
License
ISC
Repository
github
Last release
7 years ago

electron-ipc-log

Log all user-defined IPC traffic in an electron app.

npm travis standard downloads

Install

npm install electron-ipc-log

Usage

var electronIpcLog = require('electron-ipc-log')

electronIpcLog(event => {
  var { channel, data, sent, sync } = event
  var args = [sent ? '⬆️' : '⬇️', channel, ...data]
  if (sync) args.unshift('ipc:sync')
  else args.unshift('ipc')
  console.log.apply(console.log, args)
})

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 via ipcRenderer.send or ipcRenderer.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.

License

ISC

3.0.1

7 years ago

3.0.0

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago