Skip to content

Commit

Permalink
fix: prevent nil where expression
Browse files Browse the repository at this point in the history
  • Loading branch information
rosstimothy committed Sep 25, 2024
1 parent 48ead65 commit b4aee48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/events/filelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
apievents "github.com/gravitational/teleport/api/types/events"
"github.com/gravitational/teleport/lib/defaults"
"github.com/gravitational/teleport/lib/utils"
logutils "github.com/gravitational/teleport/lib/utils/log"
)

// FileLogConfig is a configuration for file log
Expand Down Expand Up @@ -344,7 +345,7 @@ func getCheckpointFromEvent(event apievents.AuditEvent) (string, error) {
}

func (l *FileLog) SearchSessionEvents(ctx context.Context, req SearchSessionEventsRequest) ([]apievents.AuditEvent, string, error) {
l.logger.DebugContext(ctx, "SearchSessionEvents", "from", req.From, "to", req.To, "order", req.Order, "limit", req.Limit, "cond", req.Cond)
l.logger.DebugContext(ctx, "SearchSessionEvents", "from", req.From, "to", req.To, "order", req.Order, "limit", req.Limit, "cond", logutils.StringerAttr(req.Cond))
filter := searchEventsFilter{eventTypes: SessionRecordingEvents}
if req.Cond != nil {
condFn, err := utils.ToFieldsCondition(req.Cond)
Expand Down
3 changes: 3 additions & 0 deletions lib/utils/log/slog_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,9 @@ func StringerAttr(s fmt.Stringer) slog.LogValuer {
}

func (s stringerAttr) LogValue() slog.Value {
if s.Stringer == nil {
return slog.StringValue("")
}
return slog.StringValue(s.Stringer.String())
}

Expand Down

0 comments on commit b4aee48

Please sign in to comment.