All checks were successful
Build and Push Docker Image to Gitea / build-and-push (push) Successful in 1m13s
Fixed the readLog() call to use the correct parameters for reading from the end of the log file. When using a negative offset to read the last N bytes, the length parameter must be 0, not a positive number. Changes: - Updated fetchMainLog default length from 4096 to 0 - Updated API route default length from '4096' to '0' Correct usage: - readLog(-4096, 0) - Read last 4096 bytes from end of file - readLog(0, 4096) - Read 4096 bytes from start of file This fixes the INCORRECT_PARAMETERS error when fetching the main supervisord log. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
24 lines
897 B
TypeScript
24 lines
897 B
TypeScript
import { NextRequest, NextResponse } from 'next/server';
|
|
import { createSupervisorClient } from '@/lib/supervisor/client';
|
|
import { withLogging } from '@/lib/utils/api-logger';
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
export const GET = withLogging(async (request: NextRequest) => {
|
|
const searchParams = request.nextUrl.searchParams;
|
|
const offset = parseInt(searchParams.get('offset') || '-4096', 10);
|
|
const length = parseInt(searchParams.get('length') || '0', 10);
|
|
|
|
const client = createSupervisorClient();
|
|
const logs = await client.readLog(offset, length);
|
|
|
|
return NextResponse.json({ logs, offset, length });
|
|
}, 'readMainLog');
|
|
|
|
export const DELETE = withLogging(async (request: NextRequest) => {
|
|
const client = createSupervisorClient();
|
|
const result = await client.clearLog();
|
|
|
|
return NextResponse.json({ success: result, message: 'Main log cleared' });
|
|
}, 'clearMainLog');
|