How to get the debug print result from a gateway scheduled event

I have a gateway script (a scheduled event). it runs well every day. there is a print function in this script. How can I get the print result?

I know I can call this gateway script in script console to get the print result. But I can 't do this as this script will changing database. Is there any other method to get the print result? Thanks!

Printing in gateway scope goes only to the wrapper log text files. Instead, you should use a logger from system.util.getLogger(), and use the INFO level methods.

1 Like

So I should change the print function to system.util.getLogger() in this gateway script. To create an INFO level log instead, then I can go to the Gateway _ Status _ Diagnostics _ Logs to find this log and then review the info. Am I right?

Yes. But for efficiency, get one logger instance at the top level of your script module, and use that instance for all your logging.

Good suggestion ! I will only create one log instance, and use it for my logging.
image
Thank you so much !

If that is a snip from a project library script (and it should be), then line 480 should be moved to near the top of the script, un-indented (outside any function). That is most efficient--one logger instance for the entire script, established on project startup when the script library is initialized.

Yes, it is a snip from my project library script inside a function (sendEmail). And this project script is overall a class (named Email). refer to below for outline of this class.

For my case, the line 480 can move to the outside of the class, or inside the class (above init() function), I think both are OK, but inside class is better. Am I right?

image

No, the logger instance setup should be outside of any class or function. If you want multiple different loggers in the same library script, make them all outside any class or function.

1 Like

Thanks for the advice. I have successfully get the log in the gateway logs.
But the string is long, how can I download it to review all details?

If you want the logged string in non-html form, you will need to either download the SQLite logs file and use an external SQLite tool, or access the wrapper.log file itself via the gateway OS.

FWIW, I generally open a remote terminal on the development gateway and use

tail --follow /path/to/install/logs/wrapper.log

while working with gateway and Perspective scripts.

1 Like

I can just use designer launcher, can not operate in gateway os. Alternatively, I made a copy of this class and made some modification, then call this new class in designer script console, successfuly got the all Email body html strings. I have found bugs in the html content and have ideas to solve them.

I think the logger is also a good tool when need get some info from gateway script.

Thank you for your kind help.

There is another good method for me. I can use system.tag.writeBlocking() function to write the string content into a memory tag, Then I can read from this tag to review details.

Haha! This is quite simple and useful for me ! :smiley:

You will be needlessly blocking all of your scripts potentially multiple times per call. Don’t do this.

On top of that, you won’t have historical record of your messages, unless you were to use a dataset tag, or multiple tags. Both of which come with potentially system crushing side effects.

Just use the method Phil suggested, really.

This gateway script runs 3 times per day (every 8hrs) and I just need this message for dubug purpose, no need historical data.
After confirm eveything goes well. I will remove it.

Thanks for your notice about the potential risk! :handshake: