[MM-41999] Add additional logging for debugging, allow users to change log level (#2031)
* Add debug logging switch * Add tests * Mock electron-log globally in jest * New logs for debugging * Switch to a dropdown to choose log levels * Fix tests * Update wording
This commit is contained in:
@@ -8,6 +8,8 @@ import Config from 'common/config';
|
||||
|
||||
import {handleConfigUpdate} from 'main/app/config';
|
||||
import {addNewServerModalWhenMainWindowIsShown} from 'main/app/intercom';
|
||||
import {setLoggingLevel} from 'main/app/utils';
|
||||
|
||||
import WindowManager from 'main/windows/windowManager';
|
||||
import AutoLauncher from 'main/AutoLauncher';
|
||||
|
||||
@@ -22,15 +24,12 @@ jest.mock('electron', () => ({
|
||||
on: jest.fn(),
|
||||
},
|
||||
}));
|
||||
jest.mock('electron-log', () => ({
|
||||
info: jest.fn(),
|
||||
error: jest.fn(),
|
||||
}));
|
||||
|
||||
jest.mock('main/app/utils', () => ({
|
||||
handleUpdateMenuEvent: jest.fn(),
|
||||
updateSpellCheckerLocales: jest.fn(),
|
||||
updateServerInfos: jest.fn(),
|
||||
setLoggingLevel: jest.fn(),
|
||||
}));
|
||||
jest.mock('main/app/intercom', () => ({
|
||||
addNewServerModalWhenMainWindowIsShown: jest.fn(),
|
||||
@@ -105,5 +104,12 @@ describe('main/app/config', () => {
|
||||
value: originalPlatform,
|
||||
});
|
||||
});
|
||||
|
||||
it('should set logging level correctly', () => {
|
||||
handleConfigUpdate({logLevel: 'info'});
|
||||
expect(setLoggingLevel).toBeCalledWith('info');
|
||||
handleConfigUpdate({logLevel: 'debug'});
|
||||
expect(setLoggingLevel).toBeCalledWith('debug');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user