diff --git a/src/utils/debugdb.ts b/src/utils/debugdb.ts index aa36d8b0..c3825f56 100644 --- a/src/utils/debugdb.ts +++ b/src/utils/debugdb.ts @@ -57,6 +57,6 @@ export function setLogItem(str: string): void { export async function getLogs(): Promise { if (db) { const all = await db.getAll('logs' as never); - downloadString(all.join('\n'), 'text/plain', `logs-${new Date().toISOString()}}.txt`); + downloadString(all.join('\n'), 'text/plain', `logs-${new Date().toISOString()}.txt`); } } diff --git a/src/utils/errorlogger.ts b/src/utils/errorlogger.ts index 2f374d83..dd180704 100644 --- a/src/utils/errorlogger.ts +++ b/src/utils/errorlogger.ts @@ -1,6 +1,13 @@ -// import { getVersionInfo } from './VERSION'; +import { getVersionInfo } from './VERSION'; +import { setLogItem } from './debugdb'; +/** + * Log a warning to both the browser console and the IndexedDB debug log. + * The debug log can be downloaded via the debug panel, making these warnings + * available in crash reports even when the DevTools console is not open. + */ export function logWarning(str: string, ...arg: unknown[]): void { - console.warn(str, ...arg); - // console.log('Version information: ', getVersionInfo()); + const detail = arg.length > 0 ? ` — ${JSON.stringify(arg)}` : ''; + setLogItem(`WARN ${str}${detail}`); + console.warn(`[${getVersionInfo().env}] ${str}`, ...arg); }