tweigel-dev / python-tuio

This repository is a python3 implementation of the TUIO protocol.
MIT License
3 stars 4 forks source link

Suppress logging #19

Open adamberenzweig opened 7 months ago

adamberenzweig commented 7 months ago

Hello! Would you accept a PR that added a verbose option to TuioClient to suppress the log messages? In our application the large volume of "Bundle received" messages is drowning out other important logging. I have a PR prepared, if you add me as a contributor I'll push the branch.

yerasiito commented 3 months ago

Maybe it is too late but I solved it without modifying the library code:

# Define a function to ignore the "Bundle recived with" message
def ignore_print_wrapper(original_func):
    def wrapper(self, address, *args):
        if args and args[0] == "fseq":
            self._call_listener()
            # You can optionally log or ignore the print statement here
            # print(f"Ignoring print statement in {original_func.__name__}")
            return
        return original_func(self, address, *args)

    return wrapper
TuioDispatcher._cursor_handler = ignore_print_wrapper(TuioDispatcher._cursor_handler)
TuioDispatcher._blob_handler = ignore_print_wrapper(TuioDispatcher._blob_handler)
TuioDispatcher._object_handler = ignore_print_wrapper(TuioDispatcher._object_handler)

# your code

It warns you because of access to a protected members of a class, but it work as expected. Also, it allow you to print your own message.