Skip to content

Commit

Permalink
Align logging for debug and trace levels (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
teran authored Jun 15, 2024
1 parent 1516ac1 commit 39ef517
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion ceph/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/cephctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ 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())
prntr := printer.New(*colorize)

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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion commands/diff/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion differ/differ.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 39ef517

Please sign in to comment.