feat: dispatch now runs on our custom loop

and can be started outside of `plugin_loaded()`

Former-commit-id: 9c8c99ed5704b4b18312e73b9b31c192805ad524
This commit is contained in:
cschen 2024-08-10 19:05:04 +02:00
parent 1b9809e167
commit 974afb98f1
2 changed files with 4 additions and 4 deletions

View file

@ -28,6 +28,7 @@ package_logger.propagate = False
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
TEXT_LISTENER = None TEXT_LISTENER = None
rt.dispatch(inner_logger.listen(), "codemp-logger")
# Initialisation and Deinitialisation # Initialisation and Deinitialisation
@ -38,8 +39,6 @@ def plugin_loaded():
# instantiate and start a global asyncio event loop. # instantiate and start a global asyncio event loop.
# pass in the exit_handler coroutine that will be called upon relasing the event loop. # pass in the exit_handler coroutine that will be called upon relasing the event loop.
# tm.acquire(disconnect_client) # tm.acquire(disconnect_client)
rt.start()
rt.dispatch(inner_logger.listen(), "codemp-logger")
TEXT_LISTENER = CodempClientTextChangeListener() TEXT_LISTENER = CodempClientTextChangeListener()

View file

@ -2,12 +2,13 @@ import logging
from asyncio import CancelledError from asyncio import CancelledError
from codemp import PyLogger from codemp import PyLogger
logger = logging.getLogger(__name__)
class CodempLogger: class CodempLogger:
def __init__(self, log_level): def __init__(self, log_level):
self.logger = logging.getLogger(__name__) self.logger = logger
self.level = log_level self.level = log_level
self.logger.setLevel(self.level)
self.internal_logger = None self.internal_logger = None
self.started = False self.started = False