def emit(self, record): level = record.levelname.lower() if level not in self.SUPPORTED_LEVELS: return exc_info = record.exc_info message = record.getMessage() or self.format(record) request = rollbar.get_request() extra_data = getattr(record, 'extra_data', {}) payload_data = getattr(record, 'payload_data', {}) self._add_history(record, payload_data) # after we've added the history data, check to see if the # notify level is satisfied if record.levelno < self.notify_level: return uuid = None try: if exc_info: if message: message_template = { 'body': { 'trace': { 'exception': { 'description': message } } } } payload_data = rollbar.dict_merge(payload_data, message_template) uuid = rollbar.report_exc_info(exc_info, level=level, request=request, extra_data=extra_data, payload_data=payload_data) else: uuid = rollbar.report_message(message, level=level, request=request, extra_data=extra_data, payload_data=payload_data) except: self.handleError(record) else: if uuid: record.rollbar_uuid = uuid
def emit(self, record): level = record.levelname.lower() if level not in self.SUPPORTED_LEVELS: return exc_info = record.exc_info # use the original message, not the formatted one message = record.msg extra_data = { 'args': record.args, 'record': { 'created': record.created, 'funcName': record.funcName, 'lineno': record.lineno, 'module': record.module, 'name': record.name, 'pathname': record.pathname, 'process': record.process, 'processName': record.processName, 'relativeCreated': record.relativeCreated, 'thread': record.thread, 'threadName': record.threadName } } extra_data.update(getattr(record, 'extra_data', {})) payload_data = getattr(record, 'payload_data', {}) self._add_history(record, payload_data) # after we've added the history data, check to see if the # notify level is satisfied if record.levelno < self.notify_level: return # Wait until we know we're going to send a report before trying to # load the request request = getattr(record, "request", None) or rollbar.get_request() uuid = None try: # when not in an exception handler, exc_info == (None, None, None) if exc_info and exc_info[0]: if message: message_template = { 'body': { 'trace': { 'exception': { 'description': message } } } } payload_data = rollbar.dict_merge(payload_data, message_template) uuid = rollbar.report_exc_info(exc_info, level=level, request=request, extra_data=extra_data, payload_data=payload_data) else: uuid = rollbar.report_message(message, level=level, request=request, extra_data=extra_data, payload_data=payload_data) except: self.handleError(record) else: if uuid: record.rollbar_uuid = uuid
def emit(self, record): level = record.levelname.lower() if level not in self.SUPPORTED_LEVELS: return exc_info = record.exc_info # use the original message, not the formatted one message = record.msg request = rollbar.get_request() extra_data = { 'args': record.args, 'record': { 'created': record.created, 'funcName': record.funcName, 'lineno': record.lineno, 'module': record.module, 'name': record.name, 'pathname': record.pathname, 'process': record.process, 'processName': record.processName, 'relativeCreated': record.relativeCreated, 'thread': record.thread, 'threadName': record.threadName } } extra_data.update(getattr(record, 'extra_data', {})) payload_data = getattr(record, 'payload_data', {}) self._add_history(record, payload_data) # after we've added the history data, check to see if the # notify level is satisfied if record.levelno < self.notify_level: return uuid = None try: if exc_info: if message: message_template = { 'body': { 'trace': { 'exception': { 'description': message } } } } payload_data = rollbar.dict_merge(payload_data, message_template) uuid = rollbar.report_exc_info(exc_info, level=level, request=request, extra_data=extra_data, payload_data=payload_data) else: uuid = rollbar.report_message(message, level=level, request=request, extra_data=extra_data, payload_data=payload_data) except: self.handleError(record) else: if uuid: record.rollbar_uuid = uuid
def emit(self, record): # If the record came from Rollbar's own logger don't report it # to Rollbar if record.name == rollbar.__log_name__: return level = record.levelname.lower() if level not in self.SUPPORTED_LEVELS: return exc_info = record.exc_info # use the original message, not the formatted one message = record.msg extra_data = { 'args': record.args, 'record': { 'created': record.created, 'funcName': record.funcName, 'lineno': record.lineno, 'module': record.module, 'name': record.name, 'pathname': record.pathname, 'process': record.process, 'processName': record.processName, 'relativeCreated': record.relativeCreated, 'thread': record.thread, 'threadName': record.threadName } } extra_data.update(getattr(record, 'extra_data', {})) payload_data = getattr(record, 'payload_data', {}) self._add_history(record, payload_data) # after we've added the history data, check to see if the # notify level is satisfied if record.levelno < self.notify_level: return # Wait until we know we're going to send a report before trying to # load the request # pylint: disable=bare-except try: request = getattr(record, "request", None) or rollbar.get_request() except: request = None uuid = None report_dict = dict( level=level, extra_data=extra_data, payload_data=payload_data) if getattr(request, 'environ', None) and request.environ.get('wsgi.input'): report_dict.update(request=request) try: # when not in an exception handler, exc_info == (None, None, None) if exc_info and exc_info[0]: if message: message_template = { 'body': { 'trace': { 'exception': { 'description': message } } } } payload_data = rollbar.dict_merge(payload_data, message_template) report_dict.update(payload_data=payload_data) uuid = rollbar.report_exc_info(exc_info, **report_dict) else: uuid = rollbar.report_message(message, **report_dict) except: self.handleError(record) else: if uuid: record.rollbar_uuid = uuid
def emit(self, record): # If the record came from Rollbar's own logger don't report it # to Rollbar if record.name == rollbar.__log_name__: return level = record.levelname.lower() if level not in self.SUPPORTED_LEVELS: return exc_info = record.exc_info # use the original message, not the formatted one message = record.msg extra_data = { 'args': record.args, 'record': { 'created': record.created, 'funcName': record.funcName, 'lineno': record.lineno, 'module': record.module, 'name': record.name, 'pathname': record.pathname, 'process': record.process, 'processName': record.processName, 'relativeCreated': record.relativeCreated, 'thread': record.thread, 'threadName': record.threadName } } extra_data.update(getattr(record, 'extra_data', {})) payload_data = getattr(record, 'payload_data', {}) self._add_history(record, payload_data) # after we've added the history data, check to see if the # notify level is satisfied if record.levelno < self.notify_level: return # Wait until we know we're going to send a report before trying to # load the request request = getattr(record, "request", None) or rollbar.get_request() uuid = None try: # when not in an exception handler, exc_info == (None, None, None) if exc_info and exc_info[0]: if message: message_template = { 'body': { 'trace': { 'exception': { 'description': message } } } } payload_data = rollbar.dict_merge(payload_data, message_template) uuid = rollbar.report_exc_info(exc_info, level=level, request=request, extra_data=extra_data, payload_data=payload_data) else: uuid = rollbar.report_message(message, level=level, request=request, extra_data=extra_data, payload_data=payload_data) except: self.handleError(record) else: if uuid: record.rollbar_uuid = uuid
def emit(self, record): record.rollbarHandled = True level = record.levelname.lower() if level not in self.SUPPORTED_LEVELS: return exc_info = record.exc_info # use the original message, not the formatted one message = record.msg extra_data = { "args": record.args, "record": { "created": record.created, "funcName": record.funcName, "lineno": record.lineno, "module": record.module, "name": record.name, "pathname": record.pathname, "process": record.process, "processName": record.processName, "relativeCreated": record.relativeCreated, "thread": record.thread, "threadName": record.threadName, }, } extra_data.update(getattr(record, "extra_data", {})) payload_data = getattr(record, "payload_data", {}) self._add_history(record, payload_data) # after we've added the history data, check to see if the # notify level is satisfied if record.levelno < self.notify_level and not record.__dict__.get("rollbar"): return # Wait until we know we're going to send a report before trying to # load the request request = getattr(record, "request", None) or rollbar.get_request() uuid = None try: if exc_info: if message: message_template = {"body": {"trace": {"exception": {"description": message}}}} payload_data = rollbar.dict_merge(payload_data, message_template) uuid = self.rollbar.report_exc_info( exc_info, level=level, request=request, extra_data=extra_data, payload_data=payload_data ) else: uuid = self.rollbar.report_message( message, level=level, request=request, extra_data=extra_data, payload_data=payload_data ) except: self.handleError(record) else: if uuid: record.rollbar_uuid = uuid