Logging¶
smok can also intercept your Python logs and send them to the server.
First you should create a SMOKDevice instance, then create an instance of and register this handler:
- class smok.logging.SMOKLogHandler(device: SMOKDevice, service_name: str)¶
A logging handler for SMOK
- Parameters
device – SMOKDevice that this logger is attached to
service_name – name of the service
Then you should add it to your list of handlers:
handler = SMOKLogHandler(sd, 'device')
logger = logging.getLogger()
logger.addHandler(handler)
Note
Service name is used to distinguish multiple processes running as the same device.
Note
Logging events are not stored for later submission. Either they are submitted at the moment, or they are lost forever. Therefore take care to log somewhere else than only to server (you can for example log to stdout)