Page 1 of 1

Debugging lua script

Posted: Fri Sep 21, 2012 5:28 pm
by JackDaniels
Hi there,

Can you tell me if it's possible to print a LUA script output to a file?

I've add some print command to a script set in the OnUserLoggedIn event but I'dd like to see what it output when it run. Only thing I see in the Domain Log is LUA script on event blabla executed successfully. I know I can copy and past it in the console on administration and get the output there but my problem happen only when it's fire by the event.

Thanks

Re: Debugging lua script

Posted: Sat Sep 22, 2012 6:24 am
by FTP
Yes, you can write the Lua script like this:

Code: Select all

local fp = assert(io.open("c:/output.log", "a+"))
fp:write("something happened!\n")
fp:close()

Re: Debugging lua script

Posted: Mon Sep 24, 2012 2:14 pm
by JackDaniels
Ahhh indeed! Shame to myself for not having thought about it....

Thanks for your help.

Re: Debugging lua script

Posted: Fri Jun 23, 2023 10:59 pm
by DomDis
FTP wrote: Sat Sep 22, 2012 6:24 am Yes, you can write the Lua script like this:

Code: Select all

local fp = assert(io.open("c:/output.log", "a+"))
fp:write("something happened!\n")
fp:close()
Can you write to the domain log ?

Re: Debugging lua script

Posted: Mon Jun 26, 2023 3:25 am
by FTP
No, you can't. You can write something to system logs or admin logs only, just use the following lua APIs:

Code: Select all

c_AddSystemLog("xxxxxx", 1)
c_AddAdminLog("xxxxxx", 1)