salve-org / collegamento

Collegamento provides an easy to use Client/Server IPC backend
https://collegamento.readthedocs.io/en/master/
MIT License
2 stars 0 forks source link

Bug Report: Remove logging #9

Closed Moosems closed 2 months ago

Moosems commented 2 months ago

Bug Report:

Bug explanation: Logging doesn't work and isn't feasible with multiprocessing How to reproduce: Use the MRE What should happen instead: It either work or it be removed. I believe that it should be removed as it won't work without forcing your own configuration Minimum reproducible example:

from logging import Logger, getLogger, DEBUG, basicConfig
from multiprocessing import Process
from time import sleep

class Server:
    def __init__(self, given_level: int) -> None:
        self.logger: Logger = getLogger("Server")

        # This technically works but is less than ideal
        basicConfig(
            level=given_level,
            format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
        )

        self.logger.info("Starting server setup")
        self.logger.warning("Level 3 minimum despite config")

class Client:
    def __init__(self, server_type: type = Server) -> None:
        basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
        self.logger: Logger = getLogger("Client") # I want to have this specific logger use this specific config
        self.logger.info("Test input from Client")

        self.main_process = Process(target=Server, args=(self.logger.getEffectiveLevel(),), daemon=True)
        self.main_process.start()

if __name__ == "__main__":
    basicConfig(
        level=DEBUG,
        format="%(asctime)s - %(message)s",
    )
    getLogger("Test").info("Outside")

    # Mini tests

    x = Client()
    sleep(1)

Traceback: N/A

OS: All Git branch: Main Commit that bug started: N/A