No messages in logfile from LUA?

Moderator: leecollings

Post Reply
Bikey
Posts: 331
Joined: Sunday 22 February 2015 12:19
Target OS: Linux
Domoticz version: 2020.x
Location: Netherlands
Contact:

No messages in logfile from LUA?

Post by Bikey »

Hi,

I'm having probably a simple problem: If I put a "print" statement in my LUA-scripts (using the internal editor, with V3.4834 stable) nothing appears in the logfile, why is that?

If I use the print statement within Blockly-scripts it does work fine.
(Loglevel from Domoticz is set to "1").
Bikey
Posts: 331
Joined: Sunday 22 February 2015 12:19
Target OS: Linux
Domoticz version: 2020.x
Location: Netherlands
Contact:

Re: No messages in logfile from LUA?

Post by Bikey »

UPDATE: if I set the loglevel to 0 the print messages from LUA show up.
That is however not implemented consequently: if I put a "print" in my Blockly scripts the messages always show up, so I would expect from LUA the same behavior.

Can that be fixed so that LUA behaves the same as Blockly with respect to logging, preferably to always show up so I can make the intelligence to do the loging in my scripts and not depend on a global setting?
Bikey
Posts: 331
Joined: Sunday 22 February 2015 12:19
Target OS: Linux
Domoticz version: 2020.x
Location: Netherlands
Contact:

Re: No messages in logfile from LUA?

Post by Bikey »

Is it only me having this issue?
User avatar
jvdz
Posts: 2445
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: No messages in logfile from LUA?

Post by jvdz »

-loglevel (0=All, 1=Status+Error, 2=Error)
Could be the LUA log messages are not considered Status or Error messages, so why not simply leave it on 0?

Jos
Bikey
Posts: 331
Joined: Sunday 22 February 2015 12:19
Target OS: Linux
Domoticz version: 2020.x
Location: Netherlands
Contact:

Re: No messages in logfile from LUA?

Post by Bikey »

That is a temporary solution, but if I do that my logfile (on a RAM-drive) fills up to much to fast. So for a real solution this needs to be implemented correctly, like it is done for Blockly
User avatar
jvdz
Posts: 2445
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: No messages in logfile from LUA?

Post by jvdz »

Just had a quick look at the source and think the Blockly writes with "LOG_STATUS" level:

Code: Select all

if (devNameNoQuotes == "WriteToLogText")
	{
		_log.Log(LOG_STATUS, "%s", doWhat.c_str());
	}
and LUA with "LOG_NORM":

Code: Select all

_log.Log(LOG_NORM, "LUA: %s", lua_tostring(lua_state, i));
So guess that needs an update to "LOG_STATUS" to get the same behavior. :)

Jos
Bikey
Posts: 331
Joined: Sunday 22 February 2015 12:19
Target OS: Linux
Domoticz version: 2020.x
Location: Netherlands
Contact:

Re: No messages in logfile from LUA?

Post by Bikey »

Thanks for looking that up, but what is the "LOG_NORM" level? Apparently that equals to loglevel = 0?
User avatar
jvdz
Posts: 2445
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: No messages in logfile from LUA?

Post by jvdz »

I am not that familiar with the domoticz source yet, but these are the options defined in logger.h:

Code: Select all

enum _eLogLevel
{
	LOG_NORM=0,
	LOG_ERROR,
	LOG_STATUS,
};
Jos
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest