Skip to content

Commit

Permalink
:electron: Making Electron server logs visible in devtools (#3219)
Browse files Browse the repository at this point in the history
* add electron logging to main browser process console

* add logging

* removing old way

* release notes
  • Loading branch information
MikesGlitch authored Aug 8, 2024
1 parent 6a85f84 commit 1abca76
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
14 changes: 13 additions & 1 deletion packages/desktop-electron/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,21 @@ function createBackgroundProcess() {
serverProcess = utilityProcess.fork(
__dirname + '/server.js',
['--subprocess', app.getVersion()],
isDev ? { execArgv: ['--inspect'] } : undefined,
isDev ? { execArgv: ['--inspect'], stdio: 'pipe' } : { stdio: 'pipe' },
);

serverProcess.stdout.on('data', (chunk: Buffer) => {
// Send the Server console.log messages to the main browser window
clientWin?.webContents.executeJavaScript(`
console.info('Server Log:', ${JSON.stringify(chunk.toString('utf8'))})`);
});

serverProcess.stderr.on('data', (chunk: Buffer) => {
// Send the Server console.error messages out to the main browser window
clientWin?.webContents.executeJavaScript(`
console.error('Server Log:', ${JSON.stringify(chunk.toString('utf8'))})`);
});

serverProcess.on('message', msg => {
switch (msg.type) {
case 'captureEvent':
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type * as T from '.';

export const captureException: T.CaptureException = function (exc) {
console.log('[Exception]', exc);
console.error('[Exception]', exc);
};

export const captureBreadcrumb: T.CaptureBreadcrumb = function () {};
6 changes: 6 additions & 0 deletions upcoming-release-notes/3219.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [MikesGlitch]
---

Makinig Server logs visible in devtools on Electron

0 comments on commit 1abca76

Please sign in to comment.