type LoggingPlugin struct {
logger *log.Logger
}
func (p *LoggingPlugin) GetName() string {
return "logging"
}
func (p *LoggingPlugin) PreHook(ctx *context.Context, req *schemas.BifrostRequest) (*schemas.BifrostRequest, *schemas.PluginShortCircuit, error) {
p.logger.Printf("Request: Provider=%s, Model=%s", req.Provider, req.Model)
return req, nil, nil
}
func (p *LoggingPlugin) PostHook(ctx *context.Context, result *schemas.BifrostResponse, err *schemas.BifrostError) (*schemas.BifrostResponse, *schemas.BifrostError, error) {
if err != nil {
p.logger.Printf("Error: %s", err.Error.Message)
} else {
p.logger.Printf("Success: Provider=%s", result.ExtraFields.Provider)
}
return result, err, nil
}
func (p *LoggingPlugin) Cleanup() error {
return nil
}