Unsure why this is not working, probably some niche reason I am unaware of.
I have two scripts that are involved here,
def universalPrint(message):
"""
Will work for vision or perspective clients now.
Args:
message: str, what do you want to print
Returns:
None
"""
from env import isVision
if isVision():
print message
else:
import system.perspective
system.perspective.print(message)
This has works fine and has been use in use for a while.
My new script which is printing, but is not logging, is
def logInfoAndPrint(message, loggerName):
"""
For instances where we want to both log to the server but also print to console for easier debugging.
Args:
message: anything as we type cast in this function for ease of use, what are we trying to print
loggerName: str, what logger are we saving this to
"""
import system.util
logger = system.util.getLogger(loggerName)
universalPrint(str(message))
universalPrint("about to log")
logger.info(message)
universalPrint("logged")
It gets to print the last “logged” statement, but I do not see the actual logged statement in my server logs.
In my console, I see
test message
about to log
09:01:55.877 [AWT-EventQueue-0] INFO test logger - test message
logged
Any ideas whats going on here? Is this not possbile?
From what context are you calling this functions? Client logging writes to the designer console when testing from the designer and i think that is what is shown in your screenshot.
Call the function from a gateway scoped script to write to the gateway log.
I am calling it from key stroke in the live client to test. I know behavior in the script console/designer is not exactly how it works in the client so I am testing it in the client.
Guess I was mistaken, I thought I had things in the client using system.util.logger to log to the server but on second look I do not. This was just a mistake on my part.
In a gateway tag change script doesn’t seem to log anything, or at least I can’t seem to be able to find it… This makes debugging quite a difficult task. Any pointer ?
An additional benefit is you can funnel multiple tag change events into the same script.
I forget the technicals but this is a safer better approach. Once you set up your tag change event this way, try your changing the tag again, see if you get logs, and if not come back and post your code/setup.
version 8.1.1, and the whole script is exactly what you posted, except it’s a gateway event tag change script.
There really is nothing to it, just a simple line of logging, but the output of which I cannot find…
@bkarabinchak.psi : This is indeed how I do it - the value changed event on tags didn’t cut it.
Can you post how you have everything setup?
Is the project enabled?
On the gateway page under Status->Gateway Scripts->Tag Change is you tag change script listed there?Any errors? On that page?