feat: Go backend, enhanced search, new widgets, Docker deploy
Major changes: - Add Go backend (backend/) with microservices architecture - Enhanced master-agents-svc: reranker, content-classifier, stealth-crawler, proxy-manager, media-search, fastClassifier, language detection - New web-svc widgets: KnowledgeCard, ProductCard, ProfileCard, VideoCard, UnifiedCard, CardGallery, InlineImageGallery, SourcesPanel, RelatedQuestions - Improved discover-svc with discover-db integration - Docker deployment improvements (Caddyfile, vendor.sh, BUILD.md) - Library-svc: project_id schema migration - Remove deprecated finance-svc and travel-svc - Localization improvements across services Made-with: Cursor
This commit is contained in:
49
backend/pkg/middleware/logging.go
Normal file
49
backend/pkg/middleware/logging.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type LoggingConfig struct {
|
||||
Logger *zap.Logger
|
||||
SkipPaths []string
|
||||
}
|
||||
|
||||
func Logging(config LoggingConfig) fiber.Handler {
|
||||
logger := config.Logger
|
||||
if logger == nil {
|
||||
logger, _ = zap.NewProduction()
|
||||
}
|
||||
|
||||
skipPaths := make(map[string]bool)
|
||||
for _, path := range config.SkipPaths {
|
||||
skipPaths[path] = true
|
||||
}
|
||||
|
||||
return func(c *fiber.Ctx) error {
|
||||
path := c.Path()
|
||||
if skipPaths[path] {
|
||||
return c.Next()
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
|
||||
err := c.Next()
|
||||
|
||||
duration := time.Since(start)
|
||||
|
||||
logger.Info("request",
|
||||
zap.String("method", c.Method()),
|
||||
zap.String("path", path),
|
||||
zap.Int("status", c.Response().StatusCode()),
|
||||
zap.Duration("latency", duration),
|
||||
zap.String("ip", c.IP()),
|
||||
zap.String("user-agent", c.Get("User-Agent")),
|
||||
)
|
||||
|
||||
return err
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user