Add `AnyLogger` type (`Logger | LoggerAdapter` alias)

According to the docs, LoggerAdapter should look mostly like Logger. So it would be really nice to have a type that can be used for both Logger and LoggerAdapter.

I would need it when I want to hold a logger instance, but I don’t really care if it’s Logger or LoggerAdapter.
So I want to support both options.

It may sound like an antipattern, according to the cookbook, but using LoggerAdapter is the recommended way of passing contextual info (according to the cookbook).

Even when using contextvars for holding the logger, a AnyLogger type would be handy indeed.

2 Likes