ynput / ayon-core

Apache License 2.0
31 stars 36 forks source link

Publish: Allow to disable printing logs to host #740

Closed BigRoy closed 1 month ago

BigRoy commented 2 years ago

Is your feature request related to a problem? Please describe.

I'd like to disable Pyblish (and potentially even OpenPype Logger logs during publishing) printing its logs into the Host DCC (e.g. Maya) as a setting when running the Pyblish UI.

Describe the solution you'd like

Be able to set e.g. a OPENPYPE_PRINT_PYBLISH_LOGS=0 or an equivalent setting to disable the printing to stderr. The logs should still get collected and handled by the UI. I'd only like to have it not propagate its logs into the host DCC.

Describe alternatives you've considered

I've tried disabling the propagating of the Pyblish loggers like this:

import logging

log = logging.getLogger("pyblish")
log.propagate = False

But that also avoids the Pyblish Pype UI to actually capture the logs. Note that the original Pyblish QML does work with propagate disabled - there the logs still get handled by the UI regardless.

Additional context

Printing in the Maya script editor has always been relatively slow - and during publishing there's relatively quite a high amount of logging/printing being done. I'd like to try and avoid the clutter in the Script Editor and at the same time likely optimize the publishing steps too.

Especially with the new publisher UI coming up the logs are much easier to debug per instance in the UI - better than the printed logs into the host DCC would allow for debugging.

First mentioned on OpenPype discord here


Of course would also love to know if this is a bad idea to begin with. :)

[cuID:OP-3914]

kalisp commented 2 years ago

It would be great if we could set logging level for Pyblish plugins.

BigRoy commented 1 year ago

Just wanted to chime in that this is very relevant for Substance Painter too. I had a case where a single self.log.info("TEST") took about 0.2 seconds if Substance's Painter logs were already quite full. Clearing the Substance Painter logs sped it up again. But that likely means not filling up its logs will be beneficial too.

As an example:

class ExampleFast(pyblish.api.InstancePlugin):
    order = pyblish.api.CollectorOrder + 0.4

    def process(self, instance):
        return

class ExampleSlow(pyblish.api.InstancePlugin):
    order = pyblish.api.CollectorOrder + 0.4

    def process(self, instance):
        self.log.info("TEST")

The fast example here would run over 30 instances pretty much instantly, the second would then take about 0.2seconds per instance if Substance Painter has a lot of previous logs still in its logs (even if the log view is disabled).

BigRoy commented 1 year ago

Also wanted to link this PR https://github.com/ynput/ayon-core/issues/817 to additionally explain how much impact logging can have on performance. Note however that if printing to the host UI isn't done it still wouldn't remove the full issue of actually still formatting and logging massive data sets as described in that issue, but it'll definitely help in some DCCs.

BigRoy commented 4 months ago

This issue coming from OpenPype is still relevant to AYON since I've still noticed slowness on the printing of logs to the host - so I transferred the issue.