Okay so that's getting me closer.
Direct pings to the function work. I'd like to wrap it in a handler so I can just use logging like I normally would. e.g.
import logging
import adsk.core, adsk.fusion, adsk.cam, traceback
class Fusion360Handler(logging.Handler):
def emit(self, record):
msg = self.format(record)
adsk.core.Application.get().userInterface.palettes.itemById('TextCommands').writeText(str(msg))
def run(context):
#Grab local logger (NOTE: Cannot put this out of function scope)
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
#Instantiate handler, set level, and add to logger.
handler = Fusion360Handler()
handler.setLevel(logging.DEBUG)
logger.addHandler(handler)
logger.info("HELLO") #THIS FAILS
Here's a basic dumb sample script. It's failing due to there being A LOT of extra loggers floating around with similar names / there seems to be multiple entries into the "run" function (e.g. enter into the function "run" multiple times)? I pared it down a little further by forcing the logger to take a unique instance/name, and even then it bugs out on logger.info.
Line 1524, in handle self.callHandlers(record) File "C:\Users\mpiep\AppData\Local\Autodesk\webdeploy\production\c1a39fe96c80078ad566b938d0f03989f4b85b09\Python\lib\logging\__init__.py", line 1585, in callHandlers if record.levelno >= hdlr.level: AttributeError: type object 'Fusion360Handler' has no attribute 'level'
Despite me looking at the handler directly and confirming it does in fact have a level attribute. I have not looked under the covers to see how these scripts are patched in....