Skip to content

Instantly share code, notes, and snippets.

@seifip
Created August 15, 2020 15:22
Show Gist options
  • Save seifip/36691abb669d7d8cd68c8a185dfa8ca0 to your computer and use it in GitHub Desktop.
Save seifip/36691abb669d7d8cd68c8a185dfa8ca0 to your computer and use it in GitHub Desktop.
from robot.libraries.BuiltIn import BuiltIn
from RPA.core.helpers import required_param
from Logger import log_to_bugsnag
class RobotLogListener:
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
ROBOT_LISTENER_API_VERSION = 3
def __init__(self):
self.ROBOT_LIBRARY_LISTENER = self
def _log_message(self, message):
severity_map = {
'FAIL': 'error',
#'WARN': 'warning',
#'INFO': 'info'
}
if(message.level in severity_map.keys()):
severity = severity_map[message.level]
current_order_id = BuiltIn().get_variable_value("${CURRENT_ORDER_ID}")
context = f"Order {current_order_id}" if current_order_id else "General"
log_to_bugsnag(message.message, severity, context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment