Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions VGraphWasm/Tests-Browser/obsidian/smoke.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([]);
});
10 changes: 8 additions & 2 deletions VGraphWasm/VGraphEditor/ConsoleLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading