Logging

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

Moderator: leecollings

Post Reply
jkimmel
Posts: 129
Joined: Monday 25 November 2013 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Mallorca
Contact:

Logging

Post by jkimmel »

This is part of a working script

Code: Select all

 if LOGGING then
            dz.log('Current temperature: ' .. temperature, dz.LOG_INFO)
            dz.log('Setpoint: ' .. tostring(setpoint), dz.LOG_INFO)
            dz.log('Current boiler state: ' .. boilerState, dz.LOG_INFO)
        end
Despite

Code: Select all

local LOGGING = true
and Domoticz settings: Errors + minimal execution info + generic info I don't see any entries in the log referring to the above code.
Rfxcom
Raspi 4
User avatar
waltervl
Posts: 5902
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Logging

Post by waltervl »

Perhaps a parsing issue due to an reserved logging section. What if you change LOGGING to CustomLog (or any other name you like)?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Logging

Post by EddyG »

Do you have code like below at the beginning of the script, and is that code correct?

Code: Select all

    logging = {
      level = domoticz.LOG_INFO,
--   level = domoticz.LOG_DEBUG,
    },
jkimmel
Posts: 129
Joined: Monday 25 November 2013 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Mallorca
Contact:

Re: Logging

Post by jkimmel »

EddyG wrote: Sunday 12 September 2021 20:27 Do you have code like below at the beginning of the script, and is that code correct?

Code: Select all

    logging = {
      level = domoticz.LOG_INFO,
--   level = domoticz.LOG_DEBUG,
    },
No I don't have. Should I?
Rfxcom
Raspi 4
User avatar
waltervl
Posts: 5902
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Logging

Post by waltervl »

jkimmel wrote: Monday 13 September 2021 11:21
EddyG wrote: Sunday 12 September 2021 20:27 Do you have code like below at the beginning of the script, and is that code correct?

Code: Select all

    logging = {
      level = domoticz.LOG_INFO,
--   level = domoticz.LOG_DEBUG,
    },
No I don't have. Should I?
Will never hurt to try and find out... ;-)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jkimmel
Posts: 129
Joined: Monday 25 November 2013 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Mallorca
Contact:

Re: Logging

Post by jkimmel »

waltervl wrote: Monday 13 September 2021 11:59
jkimmel wrote: Monday 13 September 2021 11:21
EddyG wrote: Sunday 12 September 2021 20:27 Do you have code like below at the beginning of the script, and is that code correct?

Code: Select all

    logging = {
      level = domoticz.LOG_INFO,
--   level = domoticz.LOG_DEBUG,
    },
No I don't have. Should I?
Will never hurt to try and find out... ;-)
I tried and it didn't hurt at all ;-)
Rfxcom
Raspi 4
User avatar
waltervl
Posts: 5902
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Logging

Post by waltervl »

But did you get logging now? ....
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
jkimmel
Posts: 129
Joined: Monday 25 November 2013 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Mallorca
Contact:

Re: Logging

Post by jkimmel »

waltervl wrote: Monday 13 September 2021 18:06 But did you get logging now? ....
no, but the reason has been, I tried to log a nil value and that prevented the logging of the other values

Removing logging the line with the nil value and everything was ok without defining the log level.

Anyway thanks for your input
Rfxcom
Raspi 4
EddyG
Posts: 1042
Joined: Monday 02 November 2015 5:54
Target OS: -
Domoticz version:

Re: Logging

Post by EddyG »

It is not such a bad practice to always include the logging line I presented above.
This way you can easy switch to debug logging per script.
I do it with all my scripts.
Most of the time I also include a marker, like

Code: Select all

    logging =   {
        level = domoticz.LOG_INFO,
--      level = domoticz.LOG_DEBUG,
        marker = 'ABC'
    },
You can use the marker in the filter in the log screen, so you see only the (debug) loglines of that script in the logging.
With 60+ scripts the full logging goes to fast to be interpreted.
rrozema
Posts: 470
Joined: Thursday 26 October 2017 13:37
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Delft
Contact:

Re: Logging

Post by rrozema »

Yet, -like the OP- I don't understand how to make the logging show or not show. It seems it doesn't make any difference what I specify in this logging section nor in the settings. It must be me not understanding it, but I can not get the settings so that by default dzvents scripts only show error messages and only if I am debugging a script this single script shows all messages. An example would -for me at least- be very much appreciated.
jkimmel
Posts: 129
Joined: Monday 25 November 2013 17:51
Target OS: Raspberry Pi / ODroid
Domoticz version: 2021.1
Location: Mallorca
Contact:

Re: Logging

Post by jkimmel »

rrozema wrote: Tuesday 14 September 2021 15:48 Yet, -like the OP- I don't understand how to make the logging show or not show. It seems it doesn't make any difference what I specify in this logging section nor in the settings. It must be me not understanding it, but I can not get the settings so that by default dzvents scripts only show error messages and only if I am debugging a script this single script shows all messages. An example would -for me at least- be very much appreciated.
For me as well ;)
Rfxcom
Raspi 4
User avatar
waltervl
Posts: 5902
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Logging

Post by waltervl »

Using below code AND setting dzVents logging to Silent in Setup-Settings-Other I get the following results when switching the loglevel in the script logging section. So it seems to work, but when the general dzVents logging setting in Setup-Settings-Other is already on an debug level it could be different
Edit, added a test that general setting was set to debug, in script to LOG_ERROR.

Code: Select all

return {
	on = {
	    timer = {
	        'every minute'
	       }
	},
	logging = {
		level = domoticz.LOG_INFO, -- Can be domoticz.LOG_INFO, domoticz.LOG_MODULE_EXEC_INFO, domoticz.LOG_DEBUG or domoticz.LOG_ERROR
		marker = 'test',
	},
	execute = function(domoticz, device)
	    domoticz.log('1. LOG_INFO', domoticz.LOG_INFO)
	    domoticz.log('2. LOG_MODULE_EXEC_INFO', domoticz.LOG_MODULE_EXEC_INFO)
	    domoticz.log('3. LOG_DEBUG', domoticz.LOG_DEBUG)
	    domoticz.log('4. LOG_ERROR', domoticz.LOG_ERROR)
	end
}
LOG_INFO

Code: Select all

2021-09-14 17:43:00.235 Status: dzVents: Info: test: ------ Start internal script: logging_test:, trigger: "every minute"
2021-09-14 17:43:00.236 Status: dzVents: Info: test: 1. LOG_INFO
2021-09-14 17:43:00.236 Status: dzVents: Info: test: 2. LOG_MODULE_EXEC_INFO
2021-09-14 17:43:00.236 Status: dzVents: Info: test: ------ Finished logging_test
2021-09-14 17:43:00.236 Error: dzVents: Error: (3.1.7) test: 4. LOG_ERROR
LOG_MODULE_EXEC_INFO

Code: Select all

2021-09-14 17:40:00.594 Status: dzVents: Info: test: ------ Start internal script: logging_test:, trigger: "every minute"
2021-09-14 17:40:00.595 Status: dzVents: Info: test: 2. LOG_MODULE_EXEC_INFO
2021-09-14 17:40:00.595 Status: dzVents: Info: test: ------ Finished logging_test
2021-09-14 17:40:00.595 Error: dzVents: Error: (3.1.7) test: 4. LOG_ERROR
LOG_DEBUG

Code: Select all

2021-09-14 17:45:00.335 Status: dzVents: Info: test: ------ Start internal script: logging_test:, trigger: "every minute"
2021-09-14 17:45:00.335 Status: dzVents: Info: test: 1. LOG_INFO
2021-09-14 17:45:00.335 Status: dzVents: Info: test: 2. LOG_MODULE_EXEC_INFO
2021-09-14 17:45:00.335 Status: dzVents: Debug: test: 3. LOG_DEBUG
2021-09-14 17:45:00.335 Status: dzVents: Info: test: ------ Finished logging_test
2021-09-14 17:45:00.335 Error: dzVents: Error: (3.1.7) test: 4. LOG_ERROR
LOG_ERROR

Code: Select all

2021-09-14 17:47:00.428 Error: dzVents: Error: (3.1.7) test: 4. LOG_ERROR
Script LOG_ERROR, General settings LOG_DEBUG

Code: Select all

2021-09-14 17:53:00.252 Status: dzVents: !Info: test: Debug: Writing module summary to /home/udoox86/domoticz/scripts/dzVents/module.log
2021-09-14 17:53:00.252 Error: dzVents: Error: (3.1.7) test: 4. LOG_ERROR
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 5902
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: Logging

Post by waltervl »

Dzvents logging in latest Beta 2024.4 has been simplified and also more clear and in line of other Domoticz logging.
- info logging added
- log types: info, status, error and debug
- basic control from menu setup- settings tab other
- basic setting can be overruled in the script.
See also the new logging template.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest