def setUpHandler(self): self.tearDownHandler() logger = logging.getLogger() self._handlers = logger.handlers self._level = logger.level for h in self._handlers: # TODO: fix this, for now, I don't care. logger.removeHandler(h) logger.setLevel(logging.DEBUG) sentry_handler = SentryHandler() logger.addHandler(sentry_handler)
# Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. ) INSTALLED_APPS = ( #'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'management_database', 'web_api.api', 'sentry.client', # Uncomment the next line to enable the admin: # 'django.contrib.admin', ) SENTRY_KEY = 'password goes here' SENTRY_REMOTE_URL = 'django logsentry remote URL goes here' import logging LOG_FILENAME = os.path.join(djangy_server_shared.LOGS_DIR, 'api.djangy.com/django.log') logging.basicConfig(filename=LOG_FILENAME, level=logging.DEBUG) from sentry.client.handlers import SentryHandler logging.getLogger().addHandler(SentryHandler()) # Add StreamHandler to sentry's default so you can catch missed exceptions logging.getLogger('sentry').addHandler(logging.StreamHandler())
def __init__(self, *args, **kwargs): kwargs['level'] = logging.DEBUG SentryHandler.__init__(self, *args, **kwargs)
from django.core.servers import basehttp from django.test import TestCase from django.template import TemplateSyntaxError from django.utils.encoding import smart_unicode from sentry import conf from sentry.helpers import transform from sentry.models import Message, GroupedMessage from sentry.client.base import SentryClient from sentry.client.handlers import SentryHandler from sentry.client.models import get_client from models import TestModel, DuplicateKeyModel logger = logging.getLogger('sentry.test') logger.addHandler(SentryHandler()) class TestServerThread(threading.Thread): """Thread for running a http server while tests are running.""" def __init__(self, address, port): self.address = address self.port = port self._stopevent = threading.Event() self.started = threading.Event() self.error = None super(TestServerThread, self).__init__() def run(self): """Sets up test server and database and loops over handling http requests.""" try:
)), ) #DEBUG from sentry.client.handlers import SentryHandler PATH_TO_DEBUG_LOG = os.path.join(PROJECT_ROOT, 'logs', 'debug.log') LOGGER = logging.getLogger() # Create the handler and set format for FILE HANDLER FILE_HANDLER = logging.FileHandler(PATH_TO_DEBUG_LOG) formatter = logging.Formatter( "%(asctime)s - %(name)s - %(levelname)s - %(message)s") FILE_HANDLER.setFormatter(formatter) if SentryHandler not in map(lambda x: x.__class__, LOGGER.handlers): SENTRY_HANDLER = SentryHandler() LOGGER.addHandler(SENTRY_HANDLER) # Add StreamHandler to sentry's default so you can catch missed exceptions sentry_logger = logging.getLogger('sentry.errors') sentry_logger.propagate = False sentry_logger.addHandler(logging.StreamHandler()) if not DEBUG: LDAP_LOGGER.addHandler(SENTRY_HANDLER) LOGGER.addHandler(SENTRY_HANDLER) else: LDAP_LOGGER.addHandler(FILE_HANDLER) LOGGER.addHandler(FILE_HANDLER) DEBUG = True