Resolve a workspace ID to its workflow.log path, or exit with an error.
(workspaceId: string)
| 28 | |
| 29 | /** Resolve a workspace ID to its workflow.log path, or exit with an error. */ |
| 30 | function resolveLogFile(workspaceId: string): string { |
| 31 | const workspacesDir = getWorkspacesDir(); |
| 32 | |
| 33 | // 1. Direct match |
| 34 | const directPath = path.join(workspacesDir, workspaceId, 'workflow.log'); |
| 35 | if (fs.existsSync(directPath)) return directPath; |
| 36 | |
| 37 | // 2. Resume workflow ID (e.g. workspace_resume_123) |
| 38 | const resumeBase = workspaceId.replace(/_resume_\d+$/, ''); |
| 39 | if (resumeBase !== workspaceId) { |
| 40 | const resumePath = path.join(workspacesDir, resumeBase, 'workflow.log'); |
| 41 | if (fs.existsSync(resumePath)) return resumePath; |
| 42 | } |
| 43 | |
| 44 | // 3. Named workspace ID (e.g. workspace_shannon-123) |
| 45 | const namedBase = workspaceId.replace(/_shannon-\d+$/, ''); |
| 46 | if (namedBase !== workspaceId) { |
| 47 | const namedPath = path.join(workspacesDir, namedBase, 'workflow.log'); |
| 48 | if (fs.existsSync(namedPath)) return namedPath; |
| 49 | } |
| 50 | |
| 51 | console.error(`ERROR: Workflow log not found for: ${workspaceId}`); |
| 52 | console.error(''); |
| 53 | console.error('Possible causes:'); |
| 54 | console.error(" - Workflow hasn't started yet"); |
| 55 | console.error(' - Workspace ID is incorrect'); |
| 56 | console.error(''); |
| 57 | console.error('Check the Temporal Web UI at http://localhost:8233 for workflow details'); |
| 58 | process.exit(1); |
| 59 | } |
| 60 | |
| 61 | export function logs(workspaceId: string): void { |
| 62 | const logFile = resolveLogFile(workspaceId); |
no test coverage detected