Add logging to spellcheck dictionaries loading

This commit is contained in:
Jamie Kyle 2023-09-26 09:35:14 -07:00 committed by GitHub
parent 15e9bb3d12
commit a32a345500
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 2 deletions

View File

@ -797,7 +797,8 @@ async function createWindow() {
setupSpellChecker(
mainWindow,
getPreferredSystemLocales(),
getResolvedMessagesLocale().i18n
getResolvedMessagesLocale().i18n,
getLogger()
);
if (!startInTray && windowConfig && windowConfig.maximized) {
mainWindow.maximize();

View File

@ -11,6 +11,7 @@ import { maybeParseUrl } from '../ts/util/url';
import type { MenuListType } from '../ts/types/menu';
import type { LocalizerType } from '../ts/types/Util';
import { strictAssert } from '../ts/util/assert';
import type { LoggerType } from '../ts/types/Logging';
export const FAKE_DEFAULT_LOCALE = 'en-x-ignore'; // -x- is an extension space for attaching other metadata to the locale
@ -55,9 +56,24 @@ export function getLanguages(
export const setup = (
browserWindow: BrowserWindow,
preferredSystemLocales: ReadonlyArray<string>,
i18n: LocalizerType
i18n: LocalizerType,
logger: LoggerType
): void => {
const { session } = browserWindow.webContents;
session.on('spellcheck-dictionary-download-begin', (_event, lang) => {
logger.info('spellcheck: dictionary download begin:', lang);
});
session.on('spellcheck-dictionary-download-failure', (_event, lang) => {
logger.error('spellcheck: dictionary download failure:', lang);
});
session.on('spellcheck-dictionary-download-success', (_event, lang) => {
logger.info('spellcheck: dictionary download success:', lang);
});
session.on('spellcheck-dictionary-initialized', (_event, lang) => {
logger.info('spellcheck: dictionary initialized:', lang);
});
const availableLocales = session.availableSpellCheckerLanguages;
const languages = getLanguages(
preferredSystemLocales,