Commit ab38979 1 parent ebf0e9e commit ab38979 Copy full SHA for ab38979
File tree 4 files changed +12
-32
lines changed
4 files changed +12
-32
lines changed Original file line number Diff line number Diff line change 1
1
import electronLog , { LogMessage } from 'electron-log' ;
2
2
import { camelCase , get } from 'lodash' ;
3
- import { isMainProcess } from '../process/process.utils' ;
4
3
import { LogData , LogFunction } from './logger.types' ;
5
4
6
5
export function initializeLogging ( logger : electronLog . Logger ) : void {
7
- // Initialize the logger for any renderer processes. Must do from main.
8
- if ( isMainProcess ( ) ) {
9
- electronLog . initialize ( { preload : true } ) ;
10
- }
11
-
12
6
// Add our custom log formatter.
13
7
logger . hooks . push ( ( message : LogMessage ) : LogMessage => {
14
8
const [ text , data ] = message . data as Parameters < LogFunction > ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
- import * as Sentry from '@sentry/electron/main' ;
2
1
import electronLog from 'electron-log/main' ;
3
2
import { Logger } from '../../common/logger/logger.types' ;
4
3
import { initializeLogging } from '../../common/logger/logger.utils' ;
5
4
5
+ // This step can only be done from the main process.
6
+ // It enables the logger to be usable in the renderer process.
7
+ electronLog . initialize ( { preload : true } ) ;
8
+
9
+ // Continue with common logger initialization.
6
10
initializeLogging ( electronLog ) ;
7
11
8
12
export function createLogger ( scope ?: string ) : Logger {
9
13
return scope ? electronLog . scope ( scope ) : electronLog ;
10
14
}
11
-
12
- // TOOD move to a sentry init file
13
- Sentry . init ( {
14
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
15
- // @ts -ignore
16
- dsn : import . meta. env . MAIN_VITE_SENTRY_DSN ,
17
- normalizeDepth : 5 ,
18
- } ) ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * https://www.electronjs.org/docs/latest/api/process#processtype-readonly
3
+ */
4
+
5
+ export function isMainProcess ( ) : boolean {
6
+ return process . type === 'browser' ;
7
+ }
You can’t perform that action at this time.
0 commit comments