So I see my testing message in the Help->Diagnostics->LogViewer, but I expect to also see it in the web interface Status-> Logs, where I have Scripting.ScriptManager.Project[TestLogger] set to Trace in Log Configuration.
I forget how this works exactly, but should I also be seeing a logger named test?
I have a Vision Client that runs some extrememly convoluted shared gateway script. I need to start untangling it, and I thought logging some debug level messages to capture certain values after certain user actions would be extremely useful.
Is there no way to get a message logged to the gateway? I can’t burdon the user with taking over their workstation to look at logger messages.
You say the user is running some convoluted gateway script - is it running it on the gateway via a message handler (or gateway tag change)? If so - those logs would in fact appear in the logs on your gateway webpage.
If you need the logged to the gateway, have the client send a message to a gateway message handler to run whatever you need on the gateway, and then whatever is logged in that context will be on your gateway logs.
and then from your client you can send it a payload (data pertinent to whatever you are running, if needed) via system.util.sendMessage - Ignition User Manual 8.0 - Ignition Documentation . Then, whatever happens inside that myMessageHanlder script def handleMessage(payload): - that is running on the gateway, not the client, and so any logging will go to the gateway logs.
You can go the reverse way as well, so when the gateway script finishes, you can send some result code to the client by making a Client Message Handler in a similar fashion. To do this, I’d suggest making system.util.getClientId - Ignition User Manual 8.0 - Ignition Documentation as part of your payload so that when you are done inside your gateway script, you know exactly how to target which specific client will get the result message.
Cool. So just to wrap this up and put a bow on for the next sorry sod …
In my SharedProject Gateway Event Scripts, I added a logMessageHandler:
def handleMessage(payload):
"""
This message handler will be called each time a message of this
type is received.
Arguments:
payload: A dictionary that holds the objects passed to this
message handler. Retrieve them with a subscript, e.g.
myObject = payload['argumentName']
"""
import system.util
logger = system.util.getLogger(payload['logger'])
level = payload['level'].lower()
message = payload['message']
if level == 'info':
logger.info(message)
elif level == 'trace':
logger.trace(message)
elif level == 'debug':
logger.debug(message)
elif level == 'warn':
logger.warn(message)
elif level == 'error':
logger.error(message)
elif level == 'fatal':
logger.fatal(message)
else:
logger.warn('Unknown level in logMessageHandler')