mirror of
https://github.com/lukaszraczylo/gohoarder.git
synced 2026-06-06 22:59:29 +00:00
6b037a92b4
- [x] Reorder struct fields across codebase for consistency - [x] Add analytics event handlers and tests - [x] Add authentication API key management handlers and tests - [x] Add pre-warming control handlers and tests - [x] Implement S3 storage backend with tests - [x] Implement SMB/CIFS storage backend with tests - [x] Add CDN middleware tests - [x] Integrate analytics tracking into cache manager - [x] Add S3 and SMB storage initialization in app setup - [x] Add CDN caching to proxy handlers - [x] Remove distributed locking (Redis lock manager) - [x] Remove proxy common package and utilities - [x] Remove standalone HTTP server package - [x] Remove logger middleware - [x] Simplify error handling utilities - [x] Update config with S3 and SMB options - [x] Update cache manager signature to include analytics
38 lines
784 B
Go
38 lines
784 B
Go
package logger
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/rs/zerolog"
|
|
"github.com/rs/zerolog/log"
|
|
)
|
|
|
|
// Config contains logger configuration
|
|
type Config struct {
|
|
Level string // debug, info, warn, error
|
|
Format string // json, pretty
|
|
}
|
|
|
|
// Init initializes the global logger
|
|
func Init(cfg Config) error {
|
|
// Set log level
|
|
level, err := zerolog.ParseLevel(cfg.Level)
|
|
if err != nil {
|
|
level = zerolog.InfoLevel
|
|
}
|
|
zerolog.SetGlobalLevel(level)
|
|
|
|
// Set time format
|
|
zerolog.TimeFieldFormat = zerolog.TimeFormatUnixMs
|
|
|
|
// Set format
|
|
if cfg.Format == "pretty" {
|
|
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: "15:04:05.000"})
|
|
} else {
|
|
// JSON format (default for production)
|
|
log.Logger = zerolog.New(os.Stdout).With().Timestamp().Logger()
|
|
}
|
|
|
|
return nil
|
|
}
|