Skip to content

Commit

Permalink
Merge pull request #364 from databacker/fix-log-levels
Browse files Browse the repository at this point in the history
when creating logger from existing one WithFields, ensure applying existing log levels
  • Loading branch information
deitch authored Oct 31, 2024
2 parents 9091293 + d224d59 commit 2aafa42
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/core/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func (e *Executor) Dump(opts DumpOptions) (DumpResults, error) {
maxAllowedPacket := opts.MaxAllowedPacket
filenamePattern := opts.FilenamePattern
logger := e.Logger.WithField("run", opts.Run.String())
logger.Level = e.Logger.Level

now := time.Now()
results.Time = now
Expand Down
1 change: 1 addition & 0 deletions pkg/core/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var filenameRE = regexp.MustCompile(`^db_backup_(\d{4})-(\d{2})-(\d{2})T(\d{2})[
// Prune prune older backups
func (e *Executor) Prune(opts PruneOptions) error {
logger := e.Logger.WithField("run", opts.Run.String())
logger.Level = e.Logger.Level
logger.Info("beginning prune")
var (
candidates []string
Expand Down
1 change: 1 addition & 0 deletions pkg/core/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const (
// Restore restore a specific backup into the database
func (e *Executor) Restore(opts RestoreOptions) error {
logger := e.Logger.WithField("run", opts.Run.String())
logger.Level = e.Logger.Level

logger.Info("beginning restore")
// execute pre-restore scripts if any
Expand Down
1 change: 1 addition & 0 deletions pkg/log/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func (t *telemetry) Fire(entry *log.Entry) error {
defer func() { ch <- len(entries) }()
}
l := entry.Logger.WithField(sourceField, sourceTelemetry)
l.Level = entry.Logger.Level
remoteEntries := make([]LogEntry, len(entries))
for i, entry := range entries {
// send the structured data to the telemetry endpoint
Expand Down

0 comments on commit 2aafa42

Please sign in to comment.