mirror of
https://github.com/apricote/hcloud-upload-image.git
synced 2026-01-13 21:31:03 +00:00
feat: documentation and cleanup command
This commit is contained in:
parent
27d4e3240e
commit
c9ab40b539
16 changed files with 394 additions and 148 deletions
|
|
@ -9,10 +9,13 @@ type key int
|
|||
|
||||
var loggerKey key
|
||||
|
||||
// New saves the logger as a value to the context. This can then be retrieved through [From].
|
||||
func New(ctx context.Context, logger *slog.Logger) context.Context {
|
||||
return context.WithValue(ctx, loggerKey, logger)
|
||||
}
|
||||
|
||||
// From returns the [*slog.Logger] set on the context by [New]. If there is none,
|
||||
// it returns a no-op logger that discards any output it receives.
|
||||
func From(ctx context.Context) *slog.Logger {
|
||||
if ctxLogger := ctx.Value(loggerKey); ctxLogger != nil {
|
||||
if logger, ok := ctxLogger.(*slog.Logger); ok {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue