Skip to content

Commit

Permalink
fix(logging): Changing some debug logs to be info logs where appropri…
Browse files Browse the repository at this point in the history
…ate (#63)

Changing some debug logs to be info logs where appropiate
  • Loading branch information
Jacobbrewer1 authored Feb 14, 2024
1 parent ef4359f commit 1f46ebc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions cmd/summary/cmd_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (s *serveCmd) Execute(ctx context.Context, f *flag.FlagSet, _ ...interface{
slog.Error("Error setting up purge routine", slog.String(logging.KeyError, err.Error()))
}
} else {
slog.Debug("Auto purge not set, data will not be purged")
slog.Info("Auto purge not set, data will not be purged")
}

srv := &http.Server{
Expand All @@ -102,14 +102,14 @@ func (s *serveCmd) Execute(ctx context.Context, f *flag.FlagSet, _ ...interface{
go func(srv *http.Server) {
err := srv.ListenAndServe()
if errors.Is(err, http.ErrServerClosed) {
slog.Debug("Server closed gracefully")
slog.Info("Server closed gracefully")
} else if err != nil {
slog.Error("Error serving requests", slog.String(logging.KeyError, err.Error()))
}
}(srv)

<-ctx.Done()
slog.Debug("Shutting down application")
slog.Info("Shutting down application")
if err := srv.Shutdown(ctx); err != nil {
slog.Error("Error shutting down application", slog.String(logging.KeyError, err.Error()))
return subcommands.ExitFailure
Expand Down
2 changes: 1 addition & 1 deletion cmd/summary/health.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func healthHandler() Controller {
MaxTimeInError: 0,
MaxContiguousFails: 0,
StatusListener: func(ctx context.Context, name string, state health.CheckState) {
slog.Debug("Database health check status changed",
slog.Info("Database health check status changed",
slog.String("name", name),
slog.String("state", string(state.Status)),
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/summary/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func main() {
sig := make(chan os.Signal, 1)
signal.Notify(sig, os.Interrupt, syscall.SIGTERM)
got := <-sig
slog.Debug("Received signal, shutting down", slog.String("signal", got.String()))
slog.Info("Received signal, shutting down", slog.String("signal", got.String()))
cancel()
}()

Expand Down
2 changes: 1 addition & 1 deletion cmd/summary/purge.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func setupPurge(purgeDays int) error {
}

c.Start()
slog.Debug("Cron scheduler started")
slog.Info("Cron scheduler started")
return nil
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/dataaccess/purge.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ func Purge(from time.Time) error {
if err != nil {
return fmt.Errorf("error purging data: %w", err)
} else {
slog.Debug("Data purged from database", slog.Int("affected", affected))
slog.Info("Data purged from database", slog.Int("affected", affected))
}

// Purge the data from Files out of the given range.
affected, err = Files.Purge(ctx, from)
if err != nil {
return fmt.Errorf("error purging data: %w", err)
} else {
slog.Debug("Data purged from Files", slog.Int("affected", affected))
slog.Info("Data purged from Files interface", slog.Int("affected", affected))
}
return nil
}
Expand All @@ -44,15 +44,15 @@ func PurgeAll() error {
if err != nil {
return fmt.Errorf("error purging data: %w", err)
} else {
slog.Debug("Data purged from database", slog.Int("affected", affected))
slog.Info("Data purged from database", slog.Int("affected", affected))
}

// Purge the data from Files out of the given range.
affected, err = Files.Purge(ctx, tomorrow)
if err != nil {
return fmt.Errorf("error purging data: %w", err)
} else {
slog.Debug("Data purged from Files", slog.Int("affected", affected))
slog.Info("Data purged from Files interface", slog.Int("affected", affected))
}

return nil
Expand Down

0 comments on commit 1f46ebc

Please sign in to comment.