mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-05-02 03:00:36 -04:00
chore(deps): update httplog to v3
This commit is contained in:
@@ -59,22 +59,22 @@ func NewStdLogger(outW, errW io.Writer, logLevel string) (Logger, error) {
|
||||
}
|
||||
|
||||
// DebugContext logs debug messages
|
||||
func (sl *StdLogger) DebugContext(ctx context.Context, msg string, keysAndValues ...interface{}) {
|
||||
func (sl *StdLogger) DebugContext(ctx context.Context, msg string, keysAndValues ...any) {
|
||||
sl.outLogger.DebugContext(ctx, msg, keysAndValues...)
|
||||
}
|
||||
|
||||
// InfoContext logs debug messages
|
||||
func (sl *StdLogger) InfoContext(ctx context.Context, msg string, keysAndValues ...interface{}) {
|
||||
func (sl *StdLogger) InfoContext(ctx context.Context, msg string, keysAndValues ...any) {
|
||||
sl.outLogger.InfoContext(ctx, msg, keysAndValues...)
|
||||
}
|
||||
|
||||
// WarnContext logs warning messages
|
||||
func (sl *StdLogger) WarnContext(ctx context.Context, msg string, keysAndValues ...interface{}) {
|
||||
func (sl *StdLogger) WarnContext(ctx context.Context, msg string, keysAndValues ...any) {
|
||||
sl.errLogger.WarnContext(ctx, msg, keysAndValues...)
|
||||
}
|
||||
|
||||
// ErrorContext logs error messages
|
||||
func (sl *StdLogger) ErrorContext(ctx context.Context, msg string, keysAndValues ...interface{}) {
|
||||
func (sl *StdLogger) ErrorContext(ctx context.Context, msg string, keysAndValues ...any) {
|
||||
sl.errLogger.ErrorContext(ctx, msg, keysAndValues...)
|
||||
}
|
||||
|
||||
@@ -177,21 +177,21 @@ func NewStructuredLogger(outW, errW io.Writer, logLevel string) (Logger, error)
|
||||
}
|
||||
|
||||
// DebugContext logs debug messages
|
||||
func (sl *StructuredLogger) DebugContext(ctx context.Context, msg string, keysAndValues ...interface{}) {
|
||||
func (sl *StructuredLogger) DebugContext(ctx context.Context, msg string, keysAndValues ...any) {
|
||||
sl.outLogger.DebugContext(ctx, msg, keysAndValues...)
|
||||
}
|
||||
|
||||
// InfoContext logs info messages
|
||||
func (sl *StructuredLogger) InfoContext(ctx context.Context, msg string, keysAndValues ...interface{}) {
|
||||
func (sl *StructuredLogger) InfoContext(ctx context.Context, msg string, keysAndValues ...any) {
|
||||
sl.outLogger.InfoContext(ctx, msg, keysAndValues...)
|
||||
}
|
||||
|
||||
// WarnContext logs warning messages
|
||||
func (sl *StructuredLogger) WarnContext(ctx context.Context, msg string, keysAndValues ...interface{}) {
|
||||
func (sl *StructuredLogger) WarnContext(ctx context.Context, msg string, keysAndValues ...any) {
|
||||
sl.errLogger.WarnContext(ctx, msg, keysAndValues...)
|
||||
}
|
||||
|
||||
// ErrorContext logs error messages
|
||||
func (sl *StructuredLogger) ErrorContext(ctx context.Context, msg string, keysAndValues ...interface{}) {
|
||||
func (sl *StructuredLogger) ErrorContext(ctx context.Context, msg string, keysAndValues ...any) {
|
||||
sl.errLogger.ErrorContext(ctx, msg, keysAndValues...)
|
||||
}
|
||||
|
||||
@@ -21,11 +21,11 @@ import (
|
||||
// Logger is the interface used throughout the project for logging.
|
||||
type Logger interface {
|
||||
// DebugContext is for reporting additional information about internal operations.
|
||||
DebugContext(ctx context.Context, format string, args ...interface{})
|
||||
DebugContext(ctx context.Context, format string, args ...any)
|
||||
// InfoContext is for reporting informational messages.
|
||||
InfoContext(ctx context.Context, format string, args ...interface{})
|
||||
InfoContext(ctx context.Context, format string, args ...any)
|
||||
// WarnContext is for reporting warning messages.
|
||||
WarnContext(ctx context.Context, format string, args ...interface{})
|
||||
WarnContext(ctx context.Context, format string, args ...any)
|
||||
// ErrorContext is for reporting errors.
|
||||
ErrorContext(ctx context.Context, format string, args ...interface{})
|
||||
ErrorContext(ctx context.Context, format string, args ...any)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net"
|
||||
"net/http"
|
||||
"slices"
|
||||
@@ -28,7 +29,7 @@ import (
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
"github.com/go-chi/cors"
|
||||
"github.com/go-chi/httplog/v2"
|
||||
"github.com/go-chi/httplog/v3"
|
||||
"github.com/googleapis/genai-toolbox/internal/auth"
|
||||
"github.com/googleapis/genai-toolbox/internal/embeddingmodels"
|
||||
"github.com/googleapis/genai-toolbox/internal/log"
|
||||
@@ -347,31 +348,16 @@ func NewServer(ctx context.Context, cfg ServerConfig) (*Server, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to initialize http log: %w", err)
|
||||
}
|
||||
var httpOpts httplog.Options
|
||||
switch cfg.LoggingFormat.String() {
|
||||
case "json":
|
||||
httpOpts = httplog.Options{
|
||||
JSON: true,
|
||||
LogLevel: logLevel,
|
||||
Concise: true,
|
||||
RequestHeaders: false,
|
||||
MessageFieldName: "message",
|
||||
SourceFieldName: "logging.googleapis.com/sourceLocation",
|
||||
TimeFieldName: "timestamp",
|
||||
LevelFieldName: "severity",
|
||||
}
|
||||
case "standard":
|
||||
httpOpts = httplog.Options{
|
||||
LogLevel: logLevel,
|
||||
Concise: true,
|
||||
RequestHeaders: false,
|
||||
MessageFieldName: "message",
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid Logging format: %q", cfg.LoggingFormat.String())
|
||||
|
||||
schema := httplog.SchemaGCP
|
||||
schema.Level = cfg.LogLevel.String()
|
||||
schema.Concise(true)
|
||||
httpOpts := &httplog.Options{
|
||||
Level: logLevel,
|
||||
Schema: schema,
|
||||
}
|
||||
httpLogger := httplog.NewLogger("httplog", httpOpts)
|
||||
r.Use(httplog.RequestLogger(httpLogger))
|
||||
logger := l.(*slog.Logger)
|
||||
r.Use(httplog.RequestLogger(logger, httpOpts))
|
||||
|
||||
sourcesMap, authServicesMap, embeddingModelsMap, toolsMap, toolsetsMap, promptsMap, promptsetsMap, err := InitializeConfigs(ctx, cfg)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user