Skip to content

Add contextvar logging - #786

Closed
ghost wants to merge 3 commits into
masterfrom
unknown repository
Closed

ghost wants to merge 3 commits into
masterfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Jun 20, 2020

Copy link
Copy Markdown

As discussed in #782, this would enable asyncio contextvars logging.

A task would set its context by invoking websockets.utils.set_logging_contextvar("context...").

@aaugustin

Copy link
Copy Markdown
Member

In the context of #676, I was thinking it could be even more flexible to add a logger argument to serve and connect. Then you could pass any logger you want.

That would solve your issue, wouldn't it?

@ghost

ghost commented Jun 23, 2020

Copy link
Copy Markdown
Author

Yes I suppose it would be cleaner than my current solution where I'm loading the module, grabbing the logger, wrapping it in my own adapter and injecting it back into the module using setattr.

@aaugustin

Copy link
Copy Markdown
Member

OK

As a first step, I'd rather allow users to provide their own loggers. That will be the most flexible.

As a second stop, I may consider stronger integration with asyncio with contextvars. However, I'm currently working on untangling websockets from asyncio (in order to support other I/O libraries), so I would only consider this in the asyncio-specific part that remains after this refactoring.

@ghost ghost closed this Oct 15, 2020
This was referenced May 15, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants