Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions js/plugins/google-cloud/src/gcpLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import { LoggingWinston } from '@google-cloud/logging-winston';
import { getCurrentEnv } from 'genkit';
import { logger } from 'genkit/logging';
import { Writable } from 'stream';
import { GcpTelemetryConfig } from './types';
Expand Down Expand Up @@ -56,6 +57,7 @@ export class GcpLogger {
prefix: 'genkit',
logName: 'genkit_log',
credentials: this.config.credentials,
autoRetry: true,
defaultCallback: await this.getErrorHandler(),
})
: new winston.transports.Console()
Expand Down Expand Up @@ -90,6 +92,13 @@ export class GcpLogger {
} else if (err) {
defaultLogger.error(`Unable to send logs to Google Cloud: ${err}`);
}

if (err) {
// Assume the logger is compromised, and we need a new one
// Reinitialize the genkit logger with a new instance with the same config
logger.init(new GcpLogger(this.config).getLogger(getCurrentEnv()));
defaultLogger.info('Initialized a new GcpLogger.');
}
};
}

Expand Down
Loading