slashmo / gsoc-swift-baggage-context

BaggageContext library, extracted from slashmo/gsoc-swift-tracing
https://github.com/slashmo/gsoc-swift-tracing
Apache License 2.0
4 stars 2 forks source link

Holding baggage in framework protocols #9

Closed ktoso closed 4 years ago

ktoso commented 4 years ago

Work in progress, not yet ready for review.

The names are terrible on purpose, need to find good ones.

Aims to resolve #7

ktoso commented 4 years ago

Made some progress here 🙂 Though resuming my day off, crashed falling asleep need some rest... 😉

happy 海の日 everyone 🌊 🐟

ktoso commented 4 years ago

Note to self, get it to completion this week

ktoso commented 4 years ago

Thanks for review, will push over finish line tomorrow I hope

ktoso commented 4 years ago

Thanks for the naming idea; I pushed a rework and this is good enough to get us going; I think there's some potential to make implementing these contexts easier, but we'd need changes in swift-log.

Specifically, this is a bit meh:

public struct ExampleFrameworkContext: LoggingBaggageContextCarrier {
    public var baggage: BaggageContext

    private var _logger: Logger
    public var logger: Logger {
        get {
            self._logger.with(context: self.baggage)
        }
        set {
            self._logger = newValue
        }
    }

    public init(context baggage: BaggageContext, logger: Logger) {
        self.baggage = baggage
        self._logger = logger
    }
}

but it's also the "obviously right thing/way" to impl this. Since it's structs this works fine.