From 39ef517e890993b5494869199c2b989202002bae Mon Sep 17 00:00:00 2001 From: Igor Shishkin Date: Sat, 15 Jun 2024 10:02:57 +0300 Subject: [PATCH] Align logging for debug and trace levels (#43) --- ceph/cmd.go | 2 +- cmd/cephctl/main.go | 7 ++++--- commands/diff/diff.go | 4 +++- differ/differ.go | 4 +++- service/service.go | 4 +++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ceph/cmd.go b/ceph/cmd.go index 45220f2..d1c9096 100644 --- a/ceph/cmd.go +++ b/ceph/cmd.go @@ -16,7 +16,7 @@ func mkCommand(cephBinary string, args []string) (string, []string) { outArgs := []string{"-c", strings.Join(append([]string{cephBinary}, escapedArgs...), " ")} - log.Tracef("preparing command: `%s` `%#v`", outCmd, outArgs) + log.Debugf("preparing command: `%s` `%#v`", outCmd, outArgs) return shellCommand, outArgs } diff --git a/cmd/cephctl/main.go b/cmd/cephctl/main.go index a16ebb6..e1b5e06 100644 --- a/cmd/cephctl/main.go +++ b/cmd/cephctl/main.go @@ -79,7 +79,7 @@ func main() { log.SetFormatter(&log.TextFormatter{ FullTimestamp: true, }) - log.Trace("Debug mode is enabled.") + log.Debug("Debug mode is enabled.") } svc := service.New(ceph.New(*cephBinary), differ.New()) @@ -87,7 +87,7 @@ func main() { switch appCmd { case apply.FullCommand(): - log.Tracef("running apply command") + log.Debug("running apply command") if err := applyCmd.Apply(ctx, applyCmd.ApplyConfig{ Service: svc, SpecFile: *applySpecFile, @@ -96,6 +96,7 @@ func main() { } case diff.FullCommand(): + log.Debug("running diff command") if err := diffCmd.Diff(ctx, diffCmd.DiffConfig{ Printer: prntr, Service: svc, @@ -105,7 +106,7 @@ func main() { } case dumpCephConfig.FullCommand(): - log.Tracef("running dump command") + log.Debug("running dump command") if err := dumpCephConfigCmd.DumpCephConfig(ctx, dumpCephConfigCmd.DumpCephConfigConfig{ Printer: prntr, Service: svc, diff --git a/commands/diff/diff.go b/commands/diff/diff.go index 613104a..fd1ff9b 100644 --- a/commands/diff/diff.go +++ b/commands/diff/diff.go @@ -39,7 +39,9 @@ func Diff(ctx context.Context, ac DiffConfig) error { } for _, change := range changes { - log.Tracef("change: %#v", change) + log.WithFields(log.Fields{ + "component": "command", + }).Tracef("change: %#v", change) switch change.Kind { case models.CephConfigDifferenceKindAdd: diff --git a/differ/differ.go b/differ/differ.go index 51779dd..daac1b5 100644 --- a/differ/differ.go +++ b/differ/differ.go @@ -33,7 +33,9 @@ func (d *differ) DiffCephConfig(ctx context.Context, from, to models.CephConfig) return nil, errors.Wrap(err, "error comparing current and desired configuration") } - log.Tracef("diff generated: %#v", changelog) + log.WithFields(log.Fields{ + "component": "differ", + }).Tracef("diff generated: %#v", changelog) changes := []models.CephConfigDifference{} for _, change := range changelog { diff --git a/service/service.go b/service/service.go index 9213921..46fa270 100644 --- a/service/service.go +++ b/service/service.go @@ -53,7 +53,9 @@ func (s *service) ApplyCephConfig(ctx context.Context, cfg models.CephConfig) er return errors.Wrap(err, "error comparing current and desired configuration") } - log.Tracef("changelog: %#v", changes) + log.WithFields(log.Fields{ + "component": "service", + }).Tracef("changelog: %#v", changes) for _, change := range changes { switch change.Kind {