fix: multiple calls on the root logger instead of module logger (#421)
This commit is contained in:
parent
45acd54868
commit
b7c4a3117e
@ -171,6 +171,7 @@ select = [
|
||||
"W", # pycodestyle
|
||||
"UP", # pyupgrade
|
||||
"I", # isort
|
||||
"LOG", # log
|
||||
"RUF", # ruff specific
|
||||
"FLY", # flynt
|
||||
"FURB", # refurb
|
||||
|
||||
@ -29,6 +29,8 @@ from .proxy_object import ProxyObject
|
||||
|
||||
NO_REPLY_EXPECTED_VALUE = MessageFlag.NO_REPLY_EXPECTED.value
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _generate_hello_serialized(next_serial: int) -> bytes:
|
||||
return bytes(
|
||||
@ -442,7 +444,7 @@ class MessageBus(BaseMessageBus):
|
||||
except asyncio.CancelledError:
|
||||
pass
|
||||
except Exception as e:
|
||||
logging.exception("unexpected exception in future", exc_info=e)
|
||||
_LOGGER.exception("unexpected exception in future", exc_info=e)
|
||||
|
||||
def _make_method_handler(
|
||||
self, interface: ServiceInterface, method: _Method
|
||||
@ -534,17 +536,17 @@ class MessageBus(BaseMessageBus):
|
||||
try:
|
||||
self._sock.close()
|
||||
except Exception:
|
||||
logging.warning("could not close socket", exc_info=True)
|
||||
_LOGGER.warning("could not close socket", exc_info=True)
|
||||
|
||||
def _finalize(self, err: Exception | None = None) -> None:
|
||||
try:
|
||||
self._loop.remove_reader(self._fd)
|
||||
except Exception:
|
||||
logging.warning("could not remove message reader", exc_info=True)
|
||||
_LOGGER.warning("could not remove message reader", exc_info=True)
|
||||
try:
|
||||
self._loop.remove_writer(self._fd)
|
||||
except Exception:
|
||||
logging.warning("could not remove message writer", exc_info=True)
|
||||
_LOGGER.warning("could not remove message writer", exc_info=True)
|
||||
|
||||
had_handlers = bool(self._method_return_handlers or self._user_message_handlers)
|
||||
|
||||
|
||||
@ -8,6 +8,8 @@ from typing import Callable
|
||||
from .._private.unmarshaller import Unmarshaller
|
||||
from ..message import Message
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _message_reader(
|
||||
unmarshaller: Unmarshaller,
|
||||
@ -24,7 +26,7 @@ def _message_reader(
|
||||
try:
|
||||
process(message)
|
||||
except Exception:
|
||||
logging.error("Unexpected error processing message: %s", exc_info=True)
|
||||
_LOGGER.error("Unexpected error processing message: %s", exc_info=True)
|
||||
# If we are not negotiating unix fds, we can stop reading as soon as we have
|
||||
# the buffer is empty as asyncio will call us again when there is more data.
|
||||
if (
|
||||
|
||||
@ -19,6 +19,9 @@ from ..message import Message
|
||||
from ..message_bus import BaseMessageBus
|
||||
from .proxy_object import ProxyObject
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# glib is optional
|
||||
_import_error = None
|
||||
try:
|
||||
@ -179,7 +182,7 @@ class MessageBus(BaseMessageBus):
|
||||
try:
|
||||
self._process_message(msg)
|
||||
except Exception as e:
|
||||
logging.exception(
|
||||
_LOGGER.exception(
|
||||
f"got unexpected error processing a message: {e}.\n{traceback.format_exc()}"
|
||||
)
|
||||
|
||||
|
||||
@ -334,7 +334,7 @@ class BaseMessageBus:
|
||||
try:
|
||||
raise e
|
||||
except Exception:
|
||||
logging.error(
|
||||
_LOGGER.error(
|
||||
"An exception ocurred when emitting ObjectManager.InterfacesAdded for %s. "
|
||||
"Some properties will not be included in the signal.",
|
||||
interface.name,
|
||||
@ -526,7 +526,7 @@ class BaseMessageBus:
|
||||
try:
|
||||
self._sock.shutdown(socket.SHUT_RDWR)
|
||||
except Exception:
|
||||
logging.warning("could not shut down socket", exc_info=True)
|
||||
_LOGGER.warning("could not shut down socket", exc_info=True)
|
||||
|
||||
def next_serial(self) -> int:
|
||||
"""Get the next serial for this bus. This can be used as the ``serial``
|
||||
@ -601,7 +601,7 @@ class BaseMessageBus:
|
||||
try:
|
||||
handler(None, err)
|
||||
except Exception:
|
||||
logging.warning(
|
||||
_LOGGER.warning(
|
||||
"a message handler threw an exception on shutdown", exc_info=True
|
||||
)
|
||||
|
||||
@ -804,9 +804,9 @@ class BaseMessageBus:
|
||||
self.send(e._as_message(msg))
|
||||
handled = True
|
||||
break
|
||||
logging.exception("A message handler raised an exception: %s", e)
|
||||
_LOGGER.exception("A message handler raised an exception: %s", e)
|
||||
except Exception as e:
|
||||
logging.exception("A message handler raised an exception: %s", e)
|
||||
_LOGGER.exception("A message handler raised an exception: %s", e)
|
||||
if msg.message_type is MESSAGE_TYPE_CALL:
|
||||
self.send(
|
||||
Message.new_error(
|
||||
@ -1219,11 +1219,11 @@ class BaseMessageBus:
|
||||
|
||||
def add_match_notify(msg: Message | None, err: Exception | None) -> None:
|
||||
if err:
|
||||
logging.error(
|
||||
_LOGGER.error(
|
||||
f'add match request failed. match="{self._name_owner_match_rule}", {err}'
|
||||
)
|
||||
elif msg is not None and msg.message_type == MessageType.ERROR:
|
||||
logging.error(
|
||||
_LOGGER.error(
|
||||
f'add match request failed. match="{self._name_owner_match_rule}", {msg.body[0]}'
|
||||
)
|
||||
|
||||
@ -1254,9 +1254,9 @@ class BaseMessageBus:
|
||||
|
||||
def add_match_notify(msg: Message | None, err: Exception | None) -> None:
|
||||
if err:
|
||||
logging.error(f'add match request failed. match="{match_rule}", {err}')
|
||||
_LOGGER.error(f'add match request failed. match="{match_rule}", {err}')
|
||||
elif msg is not None and msg.message_type == MessageType.ERROR:
|
||||
logging.error(
|
||||
_LOGGER.error(
|
||||
f'add match request failed. match="{match_rule}", {msg.body[0]}'
|
||||
)
|
||||
|
||||
@ -1290,11 +1290,11 @@ class BaseMessageBus:
|
||||
return
|
||||
|
||||
if err:
|
||||
logging.error(
|
||||
_LOGGER.error(
|
||||
f'remove match request failed. match="{match_rule}", {err}'
|
||||
)
|
||||
elif msg is not None and msg.message_type == MessageType.ERROR:
|
||||
logging.error(
|
||||
_LOGGER.error(
|
||||
f'remove match request failed. match="{match_rule}", {msg.body[0]}'
|
||||
)
|
||||
|
||||
|
||||
@ -19,6 +19,8 @@ from .message import Message
|
||||
from .unpack import unpack_variants as unpack
|
||||
from .validators import assert_bus_name_valid, assert_object_path_valid
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclass
|
||||
class SignalHandler:
|
||||
@ -123,7 +125,7 @@ class BaseProxyInterface:
|
||||
return
|
||||
intr_signal = match[0]
|
||||
if intr_signal.signature != msg.signature:
|
||||
logging.warning(
|
||||
_LOGGER.warning(
|
||||
f'got signal "{self.introspection.name}.{msg.member}" with unexpected signature "{msg.signature}"'
|
||||
)
|
||||
return
|
||||
@ -316,11 +318,11 @@ class BaseProxyObject:
|
||||
|
||||
def get_owner_notify(msg: Message, err: Exception | None) -> None:
|
||||
if err:
|
||||
logging.error(f'getting name owner for "{name}" failed, {err}')
|
||||
_LOGGER.error(f'getting name owner for "{name}" failed, {err}')
|
||||
return
|
||||
if msg.message_type == MessageType.ERROR:
|
||||
if msg.error_name != ErrorType.NAME_HAS_NO_OWNER.value:
|
||||
logging.error(
|
||||
_LOGGER.error(
|
||||
f'getting name owner for "{name}" failed, {msg.body[0]}'
|
||||
)
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user