Debugging lua script

You can share your Lua Scripts with everybody here.
Post Reply
JackDaniels
Posts: 2
Joined: Mon Jan 09, 2012 6:21 pm

Debugging lua script

Post 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
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Debugging lua script

Post 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()
JackDaniels
Posts: 2
Joined: Mon Jan 09, 2012 6:21 pm

Re: Debugging lua script

Post by JackDaniels »

Ahhh indeed! Shame to myself for not having thought about it....

Thanks for your help.
DomDis
Posts: 33
Joined: Sat Mar 18, 2023 7:44 pm

Re: Debugging lua script

Post 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 ?
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Debugging lua script

Post 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)
Post Reply