How to use the bugsnag.logger.exception function in bugsnag

To help you get started, we’ve selected a few bugsnag examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bugsnag / bugsnag-python / bugsnag / sessiontracker.py View on Github external
}),
            'app': {
                'releaseStage': self.config.get('release_stage'),
                'version': self.config.get('app_version')
            },
            'sessionCounts': sessions
        }

        try:
            filters = self.config.params_filters
            encoder = SanitizingJSONEncoder(separators=(',', ':'),
                                            keyword_filters=filters)
            encoded_payload = encoder.encode(payload)
            self.config.delivery.deliver_sessions(self.config, encoded_payload)
        except Exception as e:
            bugsnag.logger.exception('Sending sessions failed %s', e)
github bugsnag / bugsnag-python / bugsnag / django / __init__.py View on Github external
notification.context = "%s %s" % (request.method,
                                              request.path_info)

    if hasattr(request, 'user'):
        if callable(request.user.is_authenticated):
            is_authenticated = request.user.is_authenticated()
        else:
            is_authenticated = request.user.is_authenticated
        if is_authenticated:
            try:
                name = request.user.get_full_name()
                email = getattr(request.user, 'email', None)
                username = six.text_type(request.user.get_username())
                notification.set_user(id=username, email=email, name=name)
            except Exception:
                bugsnag.logger.exception('Could not get user data')
    else:
        notification.set_user(id=request.META['REMOTE_ADDR'])

    if getattr(request, "session", None):
        notification.add_tab("session", dict(request.session))
    notification.add_tab("request", {
        'method': request.method,
        'path': request.path,
        'encoding': request.encoding,
        'GET': dict(request.GET),
        'POST': dict(request.POST),
        'url': request.build_absolute_uri(),
    })
    notification.add_tab("environment", dict(request.META))
github bugsnag / bugsnag-python / bugsnag / notification.py View on Github external
trace = traceback.extract_tb(tb)
        else:
            trace = traceback.extract_stack()

        bugsnag_module_path = os.path.dirname(bugsnag.__file__)
        logging_module_path = os.path.dirname(logging.__file__)
        exclude_module_paths = [bugsnag_module_path, logging_module_path]
        user_exclude_modules = self.config.get("traceback_exclude_modules")
        for exclude_module in user_exclude_modules:
            try:
                module_file = exclude_module.__file__
                if module_file[-4:] == '.pyc':
                    module_file = module_file[:-1]
                exclude_module_paths.append(module_file)
            except Exception:
                bugsnag.logger.exception(
                    'Could not exclude module: %s' % repr(exclude_module))

        lib_root = self.config.get("lib_root")
        if lib_root and lib_root[-1] != os.sep:
            lib_root += os.sep

        project_root = self.config.get("project_root")
        if project_root and project_root[-1] != os.sep:
            project_root += os.sep

        stacktrace = []
        if source_func is not None:
            try:
                source = inspect.getsourcefile(source_func)
                lines = inspect.getsourcelines(source_func)
                line = 0
github bugsnag / bugsnag-python / bugsnag / utils.py View on Github external
def default(self, obj):
        """
        Coerce values to strings if possible, otherwise replace with
        '[BADENCODING]'
        """
        try:
            if six.PY3 and isinstance(obj, bytes):
                return six.text_type(obj, encoding='utf-8', errors='replace')
            else:
                return six.text_type(obj)

        except Exception:
            bugsnag.logger.exception('Could not add object to payload')
            return self.unencodeable_value