Skip to content

Commit

Permalink
Improve logging
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Frank <lukas.frank@sap.com>
  • Loading branch information
lukasfrank committed Jan 22, 2024
1 parent a4e506d commit fc71c22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions provider/cmd/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ func Command() *cobra.Command {
cmd.SetContext(ctrl.LoggerInto(cmd.Context(), ctrl.Log))
},
RunE: func(cmd *cobra.Command, args []string) error {
//flag parsing is done therefore we can silence the usage message
cmd.SilenceUsage = true
//error logging is done in the main
cmd.SilenceErrors = true
return Run(cmd.Context(), opts)
},
}
Expand Down Expand Up @@ -242,7 +246,7 @@ func Run(ctx context.Context, opts Options) error {
ceph.NewPlugin(),
emptydisk.NewPlugin(qcow2Inst, rawInst),
}); err != nil {
return fmt.Errorf("failed to initialize machine class registry: %w", err)
return fmt.Errorf("failed to initialize volume plugin manager: %w", err)
}

nicPlugin, nicPluginCleanup, err := opts.NicPlugin.NetworkInterfacePlugin()
Expand Down Expand Up @@ -302,7 +306,7 @@ func Run(ctx context.Context, opts Options) error {
setupLog.V(1).Info("Loading machine classes", "Path", opts.PathSupportedMachineClasses)
classes, err := mcr.LoadMachineClassesFile(opts.PathSupportedMachineClasses)
if err != nil {
return fmt.Errorf("failed to initialize machine class registry: %w", err)
return fmt.Errorf("failed to load machine classes: %w", err)
}

machineClasses, err := mcr.NewMachineClassRegistry(classes)
Expand Down
4 changes: 2 additions & 2 deletions provider/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package main

import (
"fmt"
"os"

"github.com/ironcore-dev/libvirt-provider/provider/cmd/app"
Expand All @@ -13,9 +12,10 @@ import (

func main() {
ctx := ctrl.SetupSignalHandler()
log := ctrl.Log.WithName("main")

if err := app.Command().ExecuteContext(ctx); err != nil {
fmt.Println(err.Error())
log.V(1).Error(err, "Error running libvirt provider")
os.Exit(1)
}
}

0 comments on commit fc71c22

Please sign in to comment.