on_log Event
Fires once for each log message.
Syntax
class ServerLogEventParams(object): @property def log_level() -> int: ... @property def message() -> str: ... @property def log_type() -> str: ... # In class Server: @property def on_log() -> Callable[[ServerLogEventParams], None]: ... @on_log.setter def on_log(event_hook: Callable[[ServerLogEventParams], None]) -> None: ...
Remarks
Logging in the component is handled through the on_log event. This will fire anytime a message is built or a response is parsed, including error messages.
When the on_log event is fired, the message in question is made available via the Message event parameter. Properties such as EphemeralKey and DeviceParams are also available when they are gathered by the Client. The other event arguments are LogType and LogLevel:
The LogType parameter indicates the type of the log entry. Possible values are:
- "Info"
- "RequestHeaders"
- "ResponseHeaders"
- "RequestBody"
- "ResponseBody"
- "ProxyRequest"
- "ProxyResponse"
- "FirewallRequest"
- "FirewallResponse"
- "AReq"
- "ARes"
- "CReq"
- "CRes"
- "RReq"
- "RRes"
- "PReq"
- "PRes"
- "Erro"
- "EphemeralKey"
- "DeviceParams"
It is recommended to output all messages raised in this event to a file for record keeping purposes, or for later debugging issues that may have come up.
The Server and Client components also have on_data_packet_in and on_data_packet_out events that fire anytime a data packet is received or sent, respectively. The entire data packet is then accessible in the DataPacket event parameter. For encrypted packets, this would contain the full encrypted data. This parameter may be inspected for advanced troubleshooting.