exception
This function logs a message with ERROR level in the Siemplify logs (both in log files and in Elasticsearch). In addition the traceback of the last exception will be written to the logs as well.
exception(message)
Parameters:
Param Name | Param Type | Possible Values | Comments | Mandatory Parameter |
---|---|---|---|---|
message | string (python 3.7) / unicode (python 2.7) |
|
The message to log. If an exception is caught, the exception object itself can be passed as well. | Yes |
In addition to the message param, additional custom parameters can be passed. The added parameters will be displayed in the matching Elasticsearch document, under the args key and can be used to log additional information regarding the log entry, i.e: the line number, the alert id, etc.
Return Type
NoneType
Example:
Sample Code
from SiemplifyLogger import SiemplifyLogger
sb = SiemplifyLogger()
try:
result = 1/0
except Exception as e:
sb.error("Division by Zero", alert_id=123)
Result Behavior
"Division by Zero" will be logged with level ERROR in the log file along with the exception traceback and a matching document will be created in Elasticsearch with args.alert_id field with value of 123.
Result Value
None