Skip to content

Commit

Permalink
fix(cmd): move log in init to catch all options
Browse files Browse the repository at this point in the history
Closes #4891
  • Loading branch information
squakez committed Dec 12, 2023
1 parent 8918cca commit daca2a5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
3 changes: 0 additions & 3 deletions pkg/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ import (
"k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/cli-runtime/pkg/printers"
"k8s.io/client-go/kubernetes/scheme"
logf "sigs.k8s.io/controller-runtime/pkg/log"

ctrl "sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log/zap"

v1 "github.com/apache/camel-k/v2/pkg/apis/camel/v1"
"github.com/apache/camel-k/v2/pkg/client"
Expand Down Expand Up @@ -337,7 +335,6 @@ func (o *runCmdOptions) run(cmd *cobra.Command, args []string) error {
signal.Notify(cs, os.Interrupt, syscall.SIGTERM)
go func() {
<-cs
logf.SetLogger(zap.New(zap.UseDevMode(true)))
if o.Context.Err() != nil {
// Context canceled
return
Expand Down
2 changes: 2 additions & 0 deletions pkg/util/log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ import (
"github.com/apache/camel-k/v2/pkg/apis/camel/v1alpha1"
"github.com/go-logr/logr"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
)

// Log --.
var Log Logger

func init() {
logf.SetLogger(zap.New(zap.UseDevMode(true)))
Log = Logger{
delegate: logf.Log.WithName("camel-k"),
}
Expand Down

0 comments on commit daca2a5

Please sign in to comment.