Domotic.Log method for python plugin framework and domoticz log levels

Python and python framework

Moderator: leecollings

Post Reply
EscApe
Posts: 535
Joined: Thursday 02 April 2015 8:46
Target OS: Linux
Domoticz version: 2020+
Location: The Netherlands
Contact:

Domotic.Log method for python plugin framework and domoticz log levels

Post by EscApe »

Hi,

I'm running the domoticz service with -loglevel 1, which should show error and status messages. With this setting anything from within a python plugin except Domoticz.Error is ignored. Even when i set the plugin to debug mode "Domoticz.Debugging(1)".

Is there a way to generate a status message from a python plugin, so they will show with -loglevel 1? Or could different log levels be implemented for python plugins?

Use cases:
My Presence detection plugin logs when devices leave or arrive. I would like to see these messages in my log, but i do not want to enable the overall -loglevel 0 for domoticz, because that will flood my log with events from energy meters (P1), z-wave devices and other less important information.

If i (purposely) enable debug mode on a plugin i would like to see debug logging, regardless of the overall domoticz log setting.
User avatar
Dnpwwo
Posts: 820
Joined: Sunday 23 March 2014 9:00
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Melbourne, Australia
Contact:

Re: Domotic.Log method for python plugin framework and domoticz log levels

Post by Dnpwwo »

@EscApe,

Couple of things, "Domoticz.Debugging(1)" is pretty verbose these days but the call now accepts a mask that will allow you to select what you see.

I'm reluctant to ignore things like the domoticz loglevel setting because one of the things I wanted to achieve with the plugins was to make them indistinguishable from either C++ brethern.

I added a 'Status' function to the Python API today (see https://www.domoticz.com/wiki/Developin ... llable_API) which may give you what you want.
The reasonable man adapts himself to the world; the unreasonable one persists to adapt the world to himself. Therefore all progress depends on the unreasonable man. George Bernard Shaw
EscApe
Posts: 535
Joined: Thursday 02 April 2015 8:46
Target OS: Linux
Domoticz version: 2020+
Location: The Netherlands
Contact:

Re: Domotic.Log method for python plugin framework and domoticz log levels

Post by EscApe »

@Dnpwwo,

That's exactly what i was asking for (or at least tried to explain;-)). Just compiled and modified my plugin, and its working like a charm.

Thanks!
pipiche
Posts: 2016
Joined: Monday 02 April 2018 20:33
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: France
Contact:

Re: Domotic.Log method for python plugin framework and domoticz log levels

Post by pipiche »

If I want to be able to use pylint and eventually debug offlie (out of Domoticz Framework), is there somewhere a Domoticz Class defined ?
Zigbee for Domoticz plugin / RPI3B+ / Electrolama ZZH-P / 45 devices

If the plugin provides you value, you can support me with a donation Paypal.

Wiki is available here.

Zigbee for Domoticz FAQ
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest