mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-11 06:31:01 -07:00
fix(core): Fix more logging issues (#7674)
This commit is contained in:
@@ -81,6 +81,7 @@ export class LoggingContentGenerator implements ContentGenerator {
|
||||
private _logApiError(
|
||||
durationMs: number,
|
||||
error: unknown,
|
||||
model: string,
|
||||
prompt_id: string,
|
||||
): void {
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
@@ -89,7 +90,7 @@ export class LoggingContentGenerator implements ContentGenerator {
|
||||
logApiError(
|
||||
this.config,
|
||||
new ApiErrorEvent(
|
||||
this.config.getModel(),
|
||||
model,
|
||||
errorMessage,
|
||||
durationMs,
|
||||
prompt_id,
|
||||
@@ -121,7 +122,7 @@ export class LoggingContentGenerator implements ContentGenerator {
|
||||
return response;
|
||||
} catch (error) {
|
||||
const durationMs = Date.now() - startTime;
|
||||
this._logApiError(durationMs, error, userPromptId);
|
||||
this._logApiError(durationMs, error, req.model, userPromptId);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -138,7 +139,7 @@ export class LoggingContentGenerator implements ContentGenerator {
|
||||
stream = await this.wrapped.generateContentStream(req, userPromptId);
|
||||
} catch (error) {
|
||||
const durationMs = Date.now() - startTime;
|
||||
this._logApiError(durationMs, error, userPromptId);
|
||||
this._logApiError(durationMs, error, req.model, userPromptId);
|
||||
throw error;
|
||||
}
|
||||
|
||||
@@ -165,15 +166,20 @@ export class LoggingContentGenerator implements ContentGenerator {
|
||||
}
|
||||
} catch (error) {
|
||||
const durationMs = Date.now() - startTime;
|
||||
this._logApiError(durationMs, error, userPromptId);
|
||||
this._logApiError(
|
||||
durationMs,
|
||||
error,
|
||||
responses[0]?.modelVersion || '',
|
||||
userPromptId,
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
const durationMs = Date.now() - startTime;
|
||||
if (lastResponse) {
|
||||
this._logApiResponse(
|
||||
durationMs,
|
||||
userPromptId,
|
||||
responses[0]?.modelVersion || '',
|
||||
userPromptId,
|
||||
lastUsageMetadata,
|
||||
JSON.stringify(responses),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user