Skip to content
This repository has been archived by the owner on Mar 14, 2022. It is now read-only.
/ electron-ipc-log Public archive

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

License

Notifications You must be signed in to change notification settings

ungoldman/electron-ipc-log

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DEPRECATED ⚠️ - This package is no longer maintained.


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(...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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published