variable logging  [Solved]

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

variable logging

Post by pvklink »

Is this possible ?, to make the logging variable by a selector switch?
when this works i will put this in a global function

error
2021-01-16 20:50:43.092 Error: dzVents: Error: (3.1.1) ...icz/scripts/dzVents/generated_scripts/DZ_schakelklok.lua:61: attempt to call a nil value (field 'devices')

Code: Select all


local function get_logtype()    
    if (domoticz.devices('logtype').state == 'info') then       --(rule 61)
        local logtype = domoticz.LOG_INFO
    elseif (domoticz.devices('logtype').state == 'error') then
        local logtype = domoticz.LOG_ERROR
    elseif (domoticz.devices('logtype').state == 'debug') then
        local logtype = domoticz.LOG_DEBUG
    elseif (domoticz.devices('logtype').state == 'exec') then
        local logtype = domoticz.LOG_MODULE_EXEC_INFO
    end
    return logtype
end
return 
{
    on ={timer = get_active_timers(Timers),},
    logging ={level   = get_logtype()},
    execute = function(dz,item,info)
    
 
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: variable logging  [Solved]

Post by waaren »

pvklink wrote: Saturday 16 January 2021 18:45 Is this possible ?, to make the logging variable by a selector switch?
Yes, but not like you coded it.

This should work.

Code: Select all

local function get_logtype(domoticz)
    if (domoticz.devices('logtype').state == 'info') then
        return domoticz.LOG_INFO
    elseif (domoticz.devices('logtype').state == 'error') then
        return domoticz.LOG_ERROR
    elseif (domoticz.devices('logtype').state == 'exec') then
        return  domoticz.LOG_MODULE_EXEC_INFO
    end
    return domoticz.LOG_DEBUG
end

return
{
    on =
    {
        timer =
        {
            'every minute',
        },
    },

    execute = function(dz,item,info)
        _G.logLevel = get_logtype(dz)
        dz.log('debug test',dz.LOG_DEBUG) -- this will only make it to the log when LOG_DEBUG is set
        dz.log('blabla',dz.LOG_FORCE) -- this will allways make it tp the log
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: variable logging

Post by pvklink »

Ok, Thanks!
I am almost there to config my different kinds of logs and messages from within the userinterface (dashticz) with a selector.
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
pvklink
Posts: 822
Joined: Wednesday 12 November 2014 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: latest b
Contact:

Re: variable logging

Post by pvklink »

everything works PERFECT !!

many thanks...(@waaren)
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest