JurgenR / aioslsk

SoulSeek client library using Python asyncio
GNU General Public License v3.0
17 stars 0 forks source link

Library: improve logging capabilities #304

Closed JurgenR closed 1 week ago

JurgenR commented 1 month ago

Filters

When debug logging is enabled all sent and received messages are logged by default. When connected to the distributed network this can generate a ton of messages so much so that more CPU time is spent on logging than on actually performing tasks. Because of this excessive logging I sometimes have to hold back on logging certain messages

There could be some default filters provided for convenience: the distributed searches are a good example.

See https://docs.python.org/3/library/logging.html#filter-objects

Metadata

The Python logging module allows for adding specific metadata to a log messages using the extra parameter of the logging. In situations where something is logged with every message, I'm specifically thinking about the IP:PORT and username in the connection module, this could be a performance improvement.

https://docs.python.org/3/library/logging.html#logging.Logger.debug

Large messages

It should be possible to cut off large messages. For example the PeerSharesReply message can get extremely large and most of it won't really matter.

Documentation

The modifications should be documented together with recommendations