[SOLVED] Logging client scoped events to gateway

Good afternoon,

I log events (info and errors) in several places of my code. Some of those errors go to the gateway and some go to the client. I want to move all client logs so they appear in the gateway.

Is there a setting I should look under? Or is this a feature of Ignition that events go their separate way depending on where they are run from?

One solution I’ve found on the forums is log my errors and info to a database.

Any thoughts on the subject are appreciated.

You can use system.util.sendMessage in your code to send your log info from the client to the gateway and create the log there with system.util.getLogger. If you have code that is executed in both client and gateway contexts, I’m guessing this would work in code that executes on the gateway too (sending the log message to itself). But I haven’t tested that case. Here’s an example of a gateway message handler for this:

def handleMessage(payload):
	This message handler will be called each time a message of this
	type is received.

		payload: A dictionary that holds the objects passed to this
		         message handler. Retrieve them with a subscript, e.g.
		         myObject = payload['argumentName']
	logger = system.util.getLogger(payload['loggerName'])
	if payload['level'] == 'fatal':
	elif payload['level'] == 'error':
	elif payload['level'] == 'warn':
	elif payload['level'] == 'info':
	elif payload['level'] == 'debug':
	elif payload['level'] == 'trace':
1 Like

That is remarkably useful… I found this vido on the subject for anyone who doesn’t understand.


Psst! Try this:

	logger = system.util.getLogger(payload['loggerName'])
	m = getattr(logger, payload['level'])