File: context.go

package info (click to toggle)
golang-github-anacrolix-log 0.13.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 148 kB
  • sloc: makefile: 2
file content (15 lines) | stat: -rw-r--r-- 320 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package log

import (
	"context"
)

var loggerContextKey interface{} = (*Logger)(nil)

func ContextWithLogger(ctx context.Context, logger Logger) context.Context {
	return context.WithValue(ctx, loggerContextKey, logger)
}

func ContextLogger(ctx context.Context) Logger {
	return ctx.Value(loggerContextKey).(Logger)
}