Page 1 of 1

Logging

Posted: Saturday 11 September 2021 21:29
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.

Re: Logging

Posted: Sunday 12 September 2021 17:41
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)?

Re: Logging

Posted: Sunday 12 September 2021 20:27
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,
    },

Re: Logging

Posted: Monday 13 September 2021 11:21
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?

Re: Logging

Posted: Monday 13 September 2021 11:59
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... ;-)

Re: Logging

Posted: Monday 13 September 2021 17:07
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 ;-)

Re: Logging

Posted: Monday 13 September 2021 18:06
by waltervl
But did you get logging now? ....

Re: Logging

Posted: Monday 13 September 2021 19:18
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

Re: Logging

Posted: Tuesday 14 September 2021 14:49
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.

Re: Logging

Posted: Tuesday 14 September 2021 15:48
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.

Re: Logging

Posted: Tuesday 14 September 2021 17:31
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 ;)

Re: Logging

Posted: Tuesday 14 September 2021 17:49
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

Re: Logging

Posted: Friday 05 July 2024 22:34
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.