Skip to content

Instantly share code, notes, and snippets.

@Klerith
Last active April 6, 2026 16:22
Show Gist options
  • Select an option

  • Save Klerith/37d4a1bb878e3dca33a267f28c055988 to your computer and use it in GitHub Desktop.

Select an option

Save Klerith/37d4a1bb878e3dca33a267f28c055988 to your computer and use it in GitHub Desktop.
Tabla para atrapar errores y depurar
const input = $input.first().json;
const validLevels = {
error: 'error',
warn: 'warn',
info: 'info',
success: 'success'
};
const level = validLevels[input.level?.toLowerCase()] || 'info';
return {
level: level,
workflow_name: input.workflow_name ?? 'unknown',
workflow_id: input.workflow_id ?? null,
execution_id: input.execution_id ?? null,
execution_mode: input.execution_mode ?? null,
node_name: input.node_name ?? null,
message: input.message ?? 'Sin mensaje',
context_data: input.context_data ? input.context_data : null,
error_stack: input.error_stack ?? null,
}
CREATE TABLE workflow_logs (
id SERIAL PRIMARY KEY,
level VARCHAR(10) NOT NULL CHECK (level IN ('error', 'warn', 'info', 'success')),
workflow_name VARCHAR(255) NOT NULL,
workflow_id VARCHAR(100),
execution_id VARCHAR(100),
execution_mode VARCHAR(50),
node_name VARCHAR(255),
message TEXT NOT NULL,
context_data JSONB,
error_stack TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
-- Índices para queries frecuentes
CREATE INDEX idx_wl_level ON workflow_logs (level);
CREATE INDEX idx_wl_workflow_name ON workflow_logs (workflow_name);
CREATE INDEX idx_wl_created_at ON workflow_logs (created_at DESC);
CREATE INDEX idx_wl_context ON workflow_logs USING GIN (context_data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment