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.
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.
Arguments:
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':
logger.fatal(payload['message'])
elif payload['level'] == 'error':
logger.error(payload['message'])
elif payload['level'] == 'warn':
logger.warn(payload['message'])
elif payload['level'] == 'info':
logger.info(payload['message'])
elif payload['level'] == 'debug':
logger.debug(payload['message'])
elif payload['level'] == 'trace':
logger.trace(payload['message'])
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']
"""
logger = system.util.getLogger(payload['loggerName'])
getattr(logger, payload['level'])(payload['message'])
Edit:
Oh, @pturmel beat me to it… by a year. Sounds about right