Gateway logs intermittent, Scrips parse differently at gateway scope

I have a tag change script on an OPC tag that is opening a project script from the "Gateway Scripting Project". The script can be called and run from the "Script Console" without error. When the tag change script is run and the logger is working the line { if scanString[0:5] == 'ERROR' } throws a { TypeError: 'NoneType' object is unsubscriptable } failure.

I don't feel like treating a string like a list to look for a substring is a typeError but it's something I can deal with.

What I can't handle is the logger failing to capture anything unless I restart the entire ignition service from windows services. Can anyone tell me how to debug the Gateway logger in 8.1 or of a better way to scrape errors caused by tag change scripts. I try deleting { system_logs.idb } from { C:\Program Files\Inductive Automation\Ignition\logs } but after a service restart I got the same intermittent behavior sometimes stuff makes it to logger sometimes it doesn't for the same inputs.

FYI I don't want to move the tag change script to a Gateway Event because I have 50 of these tags hence the UDT.

That's because it isn't a string for this error, it is a None. Find out why you are getting a None. (Share your script?)

Also note that Ignition deliberate suppresses successive identical errors that come from various events. When that is the case, you can usually get all of them by turning the corresponding logger to DEBUG.

1 Like

You are on point about the none type error, thank you!

I changed:
to DEBUG and got my error to show back up! YAY!

Error is now { TypeError: 'int' object is unsubscriptable }
New bugs == progress! YAY!

If I put a print statement into the tag change script will it show up in logger and or how do I print to console or logger from such a script?

Thank you for the help.

No, just the wrapper log. You need a logger from system.util.getLogger() to actually log something yourself. Using the logger's methods, not any form of print.

Consider defining a logger as a top-level variable in a library script in your gateway scripting project to avoid calling system.util.getLogger() in each event.


I have been able to print strings to log using the system.util.getLogger() command
But when I ask it to print the currentvalue or [.]tagname I get a return like this:
TypeError: info(): 1st arg can't be coerced to String

If I try to log a hard coded string it works. How do I get the .info or .warn to show me the value of a tag?

Use the .infof() or .warnf() methods with a %s embedded to perform printf() style formatting into a string. Logger methods are java, and are not "duck-typed" like jython.

{ Did you look at any of the examples in the user manual? }