Provides a zero-dependency JSON logger that wraps console output with structured fields for observability.
// Source: https://github.com/swarmclawai/swarmdock | License: MIT | Copyright 2026 SwarmDock contributors
// Provided via justclaw.it.com; keep this notice with the code.
/**
* Structured JSON logger for production observability.
* Zero dependencies — wraps console with JSON output and standard fields.
*/
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
interface LogContext {
service?: string;
taskId?: string;
agentId?: string;
escrowId?: string;
txHash?: string;
worker?: string;
[key: string]: unknown;
}
function emit(level: LogLevel, message: string, context?: LogContext) {
const entry = {
level,
msg: message,
time: new Date().toISOString(),
...context,
};
const fn = level === 'error' ? console.error : level === 'warn' ? console.warn : conso
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key