diff --git a/VGraphWasm/Tests-Browser/obsidian/smoke.spec.js b/VGraphWasm/Tests-Browser/obsidian/smoke.spec.js index 089962f..b2ab419 100644 --- a/VGraphWasm/Tests-Browser/obsidian/smoke.spec.js +++ b/VGraphWasm/Tests-Browser/obsidian/smoke.spec.js @@ -204,6 +204,21 @@ test('the settings tab is declared, so settings search can find it', async () => } }); +// Obsidian asks plugins not to log; the engine's debug output and Graphviz's +// warnings belong to neither the user nor the developer console. +test('rendering writes nothing to the console', async () => { + const logged = []; + const listen = (m) => logged.push(`${m.type()}: ${m.text()}`); + page.on('console', listen); + try { + await renderIn('moonstone'); + await renderIn('obsidian'); + } finally { + page.off('console', listen); + } + expect(logged).toEqual([]); +}); + test('no uncaught errors in the window', async () => { expect(pageErrors).toEqual([]); }); diff --git a/VGraphWasm/VGraphEditor/ConsoleLogger.swift b/VGraphWasm/VGraphEditor/ConsoleLogger.swift index 7d88cba..df511e7 100644 --- a/VGraphWasm/VGraphEditor/ConsoleLogger.swift +++ b/VGraphWasm/VGraphEditor/ConsoleLogger.swift @@ -4,9 +4,15 @@ import VGraph public struct ConsoleLogger: VForLogMessages { public init() {} + // Release builds ship inside the Obsidian and VS Code plugins, where nothing + // but errors belongs in the console (Obsidian's plugin guidelines). `warn` and + // `debug` arrive here too, so debug builds keep the whole trace and release + // builds only errors. public func log(_ message: String) { - let console = JSObject.global.console - _ = console.log(message) + #if DEBUG + let console = JSObject.global.console + _ = console.log(message) + #endif } public func error(_ message: String) {