Skip to content

Commit

Permalink
fix lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Janelle Law committed Oct 13, 2023
1 parent 6b5d854 commit e1cbe96
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions pkg/logger/color_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (h *colorHandler) Handle(_ context.Context, r slog.Record) error {
}

if h.appendName {
h.writeGroups(buf, h.groups)
h.writeGroups(buf)
}

if h.addSource {
Expand Down Expand Up @@ -219,7 +219,7 @@ func appendLevelDelta(buf *buffer, delta slog.Level) {
*buf = strconv.AppendInt(*buf, int64(delta), 10)
}

func (h *colorHandler) writeGroups(buf *buffer, groups []string) {
func (h *colorHandler) writeGroups(buf *buffer) {
last := len(h.groups) - 1
for i, group := range h.groups {
if i == 0 {
Expand Down
8 changes: 4 additions & 4 deletions pkg/logger/color_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,10 @@ func BenchmarkLogAttrs(b *testing.B) {
// discarder is a slog.Handler that discards all records.
type discarder struct{}

func (*discarder) Enabled(context.Context, slog.Level) bool { return true }
func (*discarder) Handle(context.Context, slog.Record) error { return nil }
func (d *discarder) WithAttrs(attrs []slog.Attr) slog.Handler { return d }
func (d *discarder) WithGroup(name string) slog.Handler { return d }
func (*discarder) Enabled(context.Context, slog.Level) bool { return true }
func (*discarder) Handle(context.Context, slog.Record) error { return nil }
func (d *discarder) WithAttrs(_ []slog.Attr) slog.Handler { return d }
func (d *discarder) WithGroup(_ string) slog.Handler { return d }

var (
testMessage = "Test logging, but use a somewhat realistic message length."
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/k8sutil/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import (
)

func NewControllerRuntimeLogger(level slog.Level) logr.Logger {
return logger.NewLogr(logger.WithTimeFormat("[15:04:05]"))
return logger.NewLogr(logger.WithTimeFormat("[15:04:05]"), logger.WithLogLevel(level))
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func WithK8sClient(k8sClient client.Client) ExternalTopologyOperatorDriverOption
}

func NewExternalTopologyOperatorDriver(
lg *slog.Logger,
opts ...ExternalTopologyOperatorDriverOption,
) (*ExternalTopologyOperatorDriver, error) {
options := ExternalTopologyOperatorDriverOptions{}
Expand Down
2 changes: 1 addition & 1 deletion plugins/topology/pkg/topology/agent/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewPlugin(ctx context.Context) *Plugin {
k8sClient: future.New[client.Client](),
}

if d, err := drivers.NewExternalTopologyOperatorDriver(lg.WithGroup("external-topology-operator")); err != nil {
if d, err := drivers.NewExternalTopologyOperatorDriver(); err != nil {
// doens't exist
lg.Info("node driver is unavailable", "driver", d.Name(),
logger.Err(err))
Expand Down

0 comments on commit e1cbe96

Please sign in to comment.