feat: add useStartupLogs hook for container startup log polling
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,7 @@ export interface LogSearchParams {
|
||||
application?: string;
|
||||
agentId?: string;
|
||||
source?: string;
|
||||
environment?: string;
|
||||
exchangeId?: string;
|
||||
logger?: string;
|
||||
from?: string;
|
||||
@@ -48,6 +49,7 @@ async function fetchLogs(params: LogSearchParams): Promise<LogSearchPageResponse
|
||||
if (params.application) urlParams.set('application', params.application);
|
||||
if (params.agentId) urlParams.set('agentId', params.agentId);
|
||||
if (params.source) urlParams.set('source', params.source);
|
||||
if (params.environment) urlParams.set('environment', params.environment);
|
||||
if (params.exchangeId) urlParams.set('exchangeId', params.exchangeId);
|
||||
if (params.logger) urlParams.set('logger', params.logger);
|
||||
if (params.from) urlParams.set('from', params.from);
|
||||
@@ -126,3 +128,28 @@ export function useApplicationLogs(
|
||||
data: query.data?.data ?? (undefined as LogEntryResponse[] | undefined),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches container startup logs for a deployment.
|
||||
* Polls every 3s while the deployment is STARTING, stops when RUNNING/FAILED.
|
||||
*/
|
||||
export function useStartupLogs(
|
||||
application: string | undefined,
|
||||
environment: string | undefined,
|
||||
deployCreatedAt: string | undefined,
|
||||
isStarting: boolean,
|
||||
) {
|
||||
const params: LogSearchParams = {
|
||||
application: application || undefined,
|
||||
environment: environment || undefined,
|
||||
source: 'container',
|
||||
from: deployCreatedAt || undefined,
|
||||
sort: 'asc',
|
||||
limit: 500,
|
||||
};
|
||||
|
||||
return useLogs(params, {
|
||||
enabled: !!application && !!deployCreatedAt,
|
||||
refetchInterval: isStarting ? 3_000 : false,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user