Skip to content

Investigate signature update

Consider updating the method signature for debug_message to be able to pass all arguments for print through. See the print API documentation...

Something like:

    def debug_message(self, debug_level:int=1, message, *args, userprefix=True, **kwargs):
        if self.debug_level >= debug_level:
            if debug_level > 0:
                prefix = ""
                if useprefix:
                    prefix = f"[D-{debug_level}] "
                message = f"{prefix}{message}"

            print(message, *args, **kwargs)

            if debug_level > 0:
                sys.stdout.flush()
        return

For reference, the real signature of print() is print(*objects, sep=' ', end='\n', file=None, flush=False):

Potential pitfalls will be to manage how print handles the file parameter, etc. testing would need to be expanded over the current version which is more narrowly focused than just a wrapper for print() with a few extra decorations.