Skip to content

Commit

Permalink
feat(menu): view application logs
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Setch <[email protected]>
  • Loading branch information
setchy committed Nov 11, 2024
1 parent d6e2d62 commit 81478d3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/main/menu.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Menu, MenuItem } from 'electron';
import { autoUpdater } from 'electron-updater';
import type { Menubar } from 'menubar';
import { resetApp, takeScreenshot } from './utils';
import { openLogsDirectory, resetApp, takeScreenshot } from './utils';

export default class MenuBuilder {
private checkForUpdatesMenuItem: MenuItem;
Expand Down Expand Up @@ -59,6 +59,10 @@ export default class MenuBuilder {
accelerator: 'CommandOrControl+S',
click: () => takeScreenshot(this.menubar),
},
{
label: 'View Application Logs',
click: () => openLogsDirectory(),
},
{
label: 'Reset App',
click: () => {
Expand Down
14 changes: 13 additions & 1 deletion src/main/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from 'node:fs';
import os from 'node:os';
import { dialog } from 'electron';
import path from 'node:path';
import { dialog, shell } from 'electron';
import log from 'electron-log';
import type { Menubar } from 'menubar';

Expand Down Expand Up @@ -35,3 +36,14 @@ export function resetApp(mb: Menubar) {
mb.app.quit();
}
}

export function openLogsDirectory() {
const logDirectory = path.dirname(log.transports.file?.getFile()?.path);

if (!logDirectory) {
log.error('Could not find log directory!');
return;
}

shell.openPath(logDirectory);
}

0 comments on commit 81478d3

Please sign in to comment.