mconnect - KDE Connect protocol implementation in Vala/C
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
394 B

  1. package logger
  2. import (
  3. "context"
  4. )
  5. type loggerKeyType int
  6. const (
  7. loggerContextKey loggerKeyType = 1
  8. )
  9. func FromContext(ctx context.Context) Logger {
  10. if logger, _ := ctx.Value(loggerContextKey).(Logger); logger != nil {
  11. return logger
  12. }
  13. return New()
  14. }
  15. func WithContext(ctx context.Context, logger Logger) context.Context {
  16. return context.WithValue(ctx, loggerContextKey, logger)
  17. }