mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-05 06:42:12 +03:00
Merge pull request #55 from diegosouzapw/feat/unified-test-logging
feat(logging): unified Logger + Proxy logging for all test flows
This commit is contained in:
@@ -99,9 +99,12 @@ export async function POST(request) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the base URL for internal requests
|
||||
* Get the base URL for internal requests (VPS-safe: respects reverse proxy headers)
|
||||
*/
|
||||
function getBaseUrl(request) {
|
||||
const fwdHost = request.headers.get("x-forwarded-host");
|
||||
const fwdProto = request.headers.get("x-forwarded-proto") || "https";
|
||||
if (fwdHost) return `${fwdProto}://${fwdHost}`;
|
||||
const url = new URL(request.url);
|
||||
return `${url.protocol}//${url.host}`;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import { validateProviderApiKey } from "@/lib/providers/validation";
|
||||
import { getCliRuntimeStatus } from "@/shared/services/cliRuntime";
|
||||
// Use the shared open-sse token refresh with built-in dedup/race-condition cache
|
||||
import { getAccessToken } from "@omniroute/open-sse/services/tokenRefresh.js";
|
||||
import { saveCallLog } from "@/lib/usageDb.js";
|
||||
import { logProxyEvent } from "@/lib/proxyLogger.js";
|
||||
|
||||
// OAuth provider test endpoints
|
||||
const OAUTH_TEST_CONFIG = {
|
||||
@@ -575,6 +577,40 @@ export async function testSingleConnection(connectionId) {
|
||||
await syncToCloudIfEnabled();
|
||||
}
|
||||
|
||||
// Log to Logger tab (call_logs table)
|
||||
try {
|
||||
saveCallLog({
|
||||
method: "POST",
|
||||
path: "/api/providers/test",
|
||||
status: result.valid ? 200 : result.statusCode || 401,
|
||||
model: "connection-test",
|
||||
provider: connection.provider,
|
||||
connectionId,
|
||||
duration: latencyMs,
|
||||
error: result.valid ? null : result.error || null,
|
||||
sourceFormat: "test",
|
||||
targetFormat: "test",
|
||||
}).catch(() => {});
|
||||
} catch {}
|
||||
|
||||
// Log to Proxy tab (proxy_logs table)
|
||||
try {
|
||||
logProxyEvent({
|
||||
status: result.valid ? "success" : "error",
|
||||
proxy: null,
|
||||
level: "provider-test",
|
||||
levelId: null,
|
||||
provider: connection.provider,
|
||||
targetUrl: `${connection.provider}/connection-test`,
|
||||
latencyMs,
|
||||
error: result.valid ? null : result.error || null,
|
||||
connectionId,
|
||||
comboId: null,
|
||||
account: connectionId?.slice(0, 8) || null,
|
||||
tlsFingerprint: false,
|
||||
});
|
||||
} catch {}
|
||||
|
||||
return {
|
||||
valid: result.valid,
|
||||
error: result.error,
|
||||
|
||||
Reference in New Issue
Block a user