Getting default logger before init

Help!, thanks for the help in advance.

I have a situation where I need to get a hold of the built in logging system, prior to the injection. This would be during the instantiation of the plugin. I want to see if a library is available during the import process and log something if it is not. I can do it later in on_after_startup looping through sys.modules, but seemed clunky to me.

Can I use the logger = logging.getLogger(name), I am not getting really anywhere with this. Nothing really works here.

Any help would be great.
Thanks

logging.getLogger("octoprint.plugins.your_plugin").warn("Dependency foo is missing")

should work just fine. That is also pretty much how the Discovery plugin does it in case of pybonjour not being available.

1 Like