Skip to content

Commit

Permalink
[controller] Replace deprecated klogr.New with textlogger.NewLogger (#20
Browse files Browse the repository at this point in the history
)

Signed-off-by: Aleksandr Zimin <[email protected]>
  • Loading branch information
AleksZimin authored Aug 30, 2024
1 parent c95ca7d commit c01392f
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions images/controller/src/pkg/logger/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ limitations under the License.
package logger

import (
"flag"
"fmt"
"strconv"

"github.com/go-logr/logr"
"k8s.io/klog/v2"
"k8s.io/klog/v2/klogr"
"k8s.io/klog/v2/textlogger"
)

const (
Expand All @@ -49,15 +48,12 @@ type Logger struct {
}

func NewLogger(level Verbosity) (*Logger, error) {
klog.InitFlags(nil)
if err := flag.Set("v", string(level)); err != nil {
v, err := strconv.Atoi(string(level))
if err != nil {
return nil, err
}
flag.Parse()

log := klogr.New().WithCallDepth(1)
// config := textlogger.NewConfig()
// log := textlogger.NewLogger(config)
log := textlogger.NewLogger(textlogger.NewConfig(textlogger.Verbosity(v))).WithCallDepth(1)

return &Logger{log: log}, nil
}
Expand Down

0 comments on commit c01392f

Please sign in to comment.