Add custom logger with source location tracking and remove verbose database logs
- Create internal/logger package with Logger wrapper around slog - Logger automatically adds source file, line number, and function name to all log entries - Use golang.org/x/term to properly detect if stdout is a terminal - Replace all slog.Logger usage with logger.Logger throughout the codebase - Remove verbose logging from database GetStats() method - Update all constructors and dependencies to use the new logger
This commit is contained in:
@@ -7,7 +7,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"git.eeqj.de/sneak/routewatch/internal/logger"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
@@ -27,7 +27,7 @@ const (
|
||||
type Snapshotter struct {
|
||||
rt *routingtable.RoutingTable
|
||||
stateDir string
|
||||
logger *slog.Logger
|
||||
logger *logger.Logger
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
mu sync.Mutex // Ensures only one snapshot runs at a time
|
||||
@@ -36,7 +36,7 @@ type Snapshotter struct {
|
||||
}
|
||||
|
||||
// New creates a new Snapshotter instance
|
||||
func New(rt *routingtable.RoutingTable, cfg *config.Config, logger *slog.Logger) (*Snapshotter, error) {
|
||||
func New(rt *routingtable.RoutingTable, cfg *config.Config, logger *logger.Logger) (*Snapshotter, error) {
|
||||
stateDir := cfg.GetStateDir()
|
||||
|
||||
// If state directory is specified, ensure it exists
|
||||
|
||||
Reference in New Issue
Block a user