예제 #1
0
def sentry_alert(*args, **kwargs):
    if sentry_exceptions_enabled():
        try:
            get_sentry_client().captureException(*args, **kwargs)
        except URLError:
            logger = get_logger()
            logger.error('Error occured when sending exception to Sentry')
예제 #2
0
def sentry_alert(*args, **kwargs):
    if sentry_exceptions_enabled():
        try:
            get_sentry_client().captureException(*args, **kwargs)
        except URLError:
            logger = get_logger()
            logger.error('Error occured when sending exception to Sentry')
예제 #3
0
def log_uncaught_errors(logger=None, **kwargs):
    """
    Helper to log uncaught exceptions.

    All additional kwargs supplied will be sent to Sentry as extra data.

    Parameters
    ----------
    logger: structlog.BoundLogger, optional
        The logging object to write to.

    """
    logger = logger or get_logger()
    logger.error('Uncaught error', exc_info=True, **kwargs)
    sentry_alert(tags=kwargs)
예제 #4
0
def log_uncaught_errors(logger=None, **kwargs):
    """
    Helper to log uncaught exceptions.

    All additional kwargs supplied will be sent to Sentry as extra data.

    Parameters
    ----------
    logger: structlog.BoundLogger, optional
        The logging object to write to.

    """
    logger = logger or get_logger()
    logger.error('Uncaught error', exc_info=True, **kwargs)
    sentry_alert(tags=kwargs)
예제 #5
0
파일: err.py 프로젝트: busseyl/sync-engine
import sys
import traceback

from flask import jsonify, make_response, request
from nylas.logging.sentry import sentry_alert
from nylas.logging.log import get_logger, create_error_log_context
log = get_logger()

from inbox.config import is_live_env


def get_request_uid(headers):
    return headers.get('X-Unique-ID')


def log_exception(exc_info, send_to_sentry=True, **kwargs):
    """ Add exception info to the log context for the request.

    We do not log in a separate log statement in order to make debugging
    easier. As a bonus, this reduces log volume somewhat.

    """
    if send_to_sentry:
        sentry_alert()

    if not is_live_env():
        print
        traceback.print_exc()
        print

    new_log_context = create_error_log_context(exc_info)
예제 #6
0
import sys
import traceback

from flask import jsonify, make_response, request
from nylas.logging.sentry import sentry_alert
from nylas.logging.log import safe_format_exception, get_logger
log = get_logger()

from inbox.config import is_live_env


def get_request_uid(headers):
    return headers.get('X-Unique-ID')


def log_exception(exc_info, send_to_sentry=True, **kwargs):
    """ Add exception info to the log context for the request.

    We do not log in a separate log statement in order to make debugging
    easier. As a bonus, this reduces log volume somewhat.

    """
    if send_to_sentry:
        sentry_alert()

    if not is_live_env():
        print
        traceback.print_exc()
        print

    exc_type, exc_value, exc_tb = exc_info