Skip to content

Commit

Permalink
Please the linter.
Browse files Browse the repository at this point in the history
  • Loading branch information
paddycarver committed May 11, 2024
1 parent 37d694c commit 4a458c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion js.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func getComponentJSEmbeds(ctx context.Context, component Component) template.JS
seen[checksum] = struct{}{}
results += template.JS(fmt.Sprintf(`
/* embedded JavaScript from %T */
%s`, comp, script))
%s`, comp, script)) // #nosec G203
}
return results
}
Expand Down
14 changes: 12 additions & 2 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,34 @@ func logger(ctx context.Context) *slog.Logger {
return logger
}

// LoggingContext returns a context.Context with the slog.Logger embedded in it
// in such a way that temple will be able to find it. Passing the returned
// context.Context to temple functions will let temple write its logging output
// to that logger.
func LoggingContext(ctx context.Context, logger *slog.Logger) context.Context {
return context.WithValue(ctx, slogCtxKey, logger)
}

type noopHandler struct{}

// Enabled always returns false for the noopHandler.
func (noopHandler) Enabled(_ context.Context, _ slog.Level) bool {
return false
}

// Handle always returns a nil error and does nothing else for the noopHandler.
func (noopHandler) Handle(_ context.Context, _ slog.Record) error {
return nil
}

func (n noopHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
// WithAttrs always returns the noopHandler as it was before WithAttrs was
// called.
func (n noopHandler) WithAttrs(_ []slog.Attr) slog.Handler {
return n
}

func (n noopHandler) WithGroup(name string) slog.Handler {
// WithGroup always returns the noopHandler as it was before WithGroup was
// called.
func (n noopHandler) WithGroup(_ string) slog.Handler {
return n
}

0 comments on commit 4a458c8

Please sign in to comment.