Last active
April 6, 2026 16:22
-
-
Save Klerith/37d4a1bb878e3dca33a267f28c055988 to your computer and use it in GitHub Desktop.
Tabla para atrapar errores y depurar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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