Formats various values into string for console logging.
// Source: https://github.com/janhq/jan | License: Apache-2.0 | Copyright 2025 Menlo Research
// Provided via justclaw.it.com; keep this notice with the code.
/**
* Shared logger for extensions.
*
* Emits through the standard `console` methods; the web-app installs a
* console interceptor that forwards these to `app.log` via the Tauri log
* plugin with matching levels. Extensions must not call the log plugin
* directly or lines would be duplicated in `app.log`.
* @module
*/
export function formatLogArg(arg: unknown): string {
if (arg instanceof Error) {
return arg.stack ? `${arg.message}\n${arg.stack}` : arg.message
}
if (arg === null || arg === undefined) return String(arg)
if (typeof arg === 'object') {
try {
return JSON.stringify(arg)
} catch {
r
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key