• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.get_client函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sentry.client.models.get_client函数的典型用法代码示例。如果您正苦于以下问题:Python get_client函数的具体用法?Python get_client怎么用?Python get_client使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_client函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: testAlternateDatabase

 def testAlternateDatabase(self):
     settings.DATABASE_USING = 'default'
     
     try:
         Message.objects.get(id=999999979)
     except Message.DoesNotExist, exc:
         get_client().create_from_exception(exc)
开发者ID:klipstein,项目名称:django-sentry,代码行数:7,代码来源:tests.py


示例2: testExclusionViewPath

 def testExclusionViewPath(self):
     try: Message.objects.get(pk=1341324)
     except: get_client().create_from_exception()
     
     last = Message.objects.get()
     
     self.assertEquals(last.view, 'sentry.tests.tests.testExclusionViewPath')
开发者ID:carmi,项目名称:django-sentry,代码行数:7,代码来源:tests.py


示例3: emit

    def emit(self, record):
        from sentry.client.models import get_client

        # Avoid typical config issues by overriding loggers behavior
        if record.name == 'sentry.errors':
            print >> sys.stderr, "Recursive log message sent to SentryHandler"
            print >> sys.stderr, record.message
            return

        get_client().create_from_record(record)
开发者ID:Bounder,项目名称:django-sentry,代码行数:10,代码来源:handlers.py


示例4: test_best_guess_view

 def test_best_guess_view(self):
     settings.EXCLUDE_PATHS = ['tests.tests']
     
     try: Message.objects.get(pk=1341324)
     except: get_client().create_from_exception()
     
     last = Message.objects.get()
     
     self.assertEquals(last.view, 'tests.tests.test_best_guess_view')
     
     settings.EXCLUDE_PATHS = []
开发者ID:olarcheveque,项目名称:django-sentry,代码行数:11,代码来源:tests.py


示例5: testBestGuessView

 def testBestGuessView(self):
     conf.EXCLUDE_PATHS = ['sentry.tests.tests']
     
     try: Message.objects.get(pk=1341324)
     except: get_client().create_from_exception()
     
     last = Message.objects.get()
     
     self.assertEquals(last.view, 'sentry.tests.tests.testBestGuessView')
     
     conf.EXCLUDE_PATHS = []
开发者ID:carmi,项目名称:django-sentry,代码行数:11,代码来源:tests.py


示例6: log_with_stacktrace

def log_with_stacktrace(message, level=logging.INFO, logger='hiicart.audit'):
    client = get_client()
    if client is None:
        logger = logging.get_logger()
        logger.warn("Could not save stack trace for message: %s" % message)
        return
    kwargs = dict(level=level, logger=logger)
    stack = inspect.stack()[1:]
    tb = FakeTraceback(stack)
    exc_info = (AuditingStacktrace, AuditingStacktrace(message), tb)
    get_client().create_from_exception(exc_info, **kwargs)
开发者ID:kbourgoin,项目名称:hiicart,代码行数:11,代码来源:auditing.py


示例7: testThrashing

 def testThrashing(self):
     settings.THRASHING_LIMIT = 10
     settings.THRASHING_TIMEOUT = 60
     
     Message.objects.all().delete()
     GroupedMessage.objects.all().delete()
     
     for i in range(0, 50):
         get_client().create_from_text('hi')
     
     self.assertEquals(Message.objects.count(), settings.THRASHING_LIMIT)
开发者ID:klipstein,项目名称:django-sentry,代码行数:11,代码来源:tests.py


示例8: testNoThrashing

    def testNoThrashing(self):
        prev = settings.THRASHING_LIMIT
        settings.THRASHING_LIMIT = 0
        
        Message.objects.all().delete()
        GroupedMessage.objects.all().delete()
        
        for i in range(0, 50):
            get_client().create_from_text('hi')
        
        self.assertEquals(Message.objects.count(), 50)

        settings.THRASHING_LIMIT = prev
开发者ID:klipstein,项目名称:django-sentry,代码行数:13,代码来源:tests.py


示例9: emit

    def emit(self, record):
        from sentry.client.models import get_client
        from sentry.client.middleware import SentryLogMiddleware

        # Fetch the request from a threadlocal variable, if available
        request = getattr(SentryLogMiddleware.thread, "request", None)

        # Avoid typical config issues by overriding loggers behavior
        if record.name == "sentry.errors":
            print >>sys.stderr, "Recursive log message sent to SentryHandler"
            print >>sys.stderr, record.message
            return

        get_client().create_from_record(record, request=request)
开发者ID:harmv,项目名称:django-sentry,代码行数:14,代码来源:handlers.py


示例10: testLongURLs

    def testLongURLs(self):
        # Fix: #6 solves URLs > 200 characters
        message_id = get_client().create_from_text('hello world', url='a'*210)
        error = Message.objects.get(message_id=message_id)

        self.assertEquals(error.url, 'a'*200)
        self.assertEquals(error.data['url'], 'a'*210)
开发者ID:carmi,项目名称:django-sentry,代码行数:7,代码来源:tests.py


示例11: testAPI

 def testAPI(self):
     try:
         Message.objects.get(id=999999989)
     except Message.DoesNotExist, exc:
         message_id = get_client().create_from_exception()
         error = Message.objects.get(message_id=message_id)
         self.assertTrue(error.data.get('__sentry__', {}).get('exc'))
开发者ID:carmi,项目名称:django-sentry,代码行数:7,代码来源:tests.py


示例12: process_response

 def process_response(self, request, response):
     if response.status_code == 404 and request.META.get('HTTP_REFERER', '') and not sentry_settings.DEBUG:
         request.META['TURANUSER'] = request.user
         message_id = get_client().create_from_text('Http 404 %s' %request.path, request=request, level=logging.INFO, logger='http404')
         request.sentry = {
             'id': message_id,
             }
     return response
开发者ID:bolav,项目名称:Turan,代码行数:8,代码来源:middleware.py


示例13: process_response

 def process_response(self, request, response):
     if response.status_code != 404:
         return response
     message_id = get_client().create_from_text('Http 404', request=request, level=logging.INFO, logger='http404')
     request.sentry = {
         'id': message_id,
     }
     return response
开发者ID:TradeHill2011,项目名称:django-sentry,代码行数:8,代码来源:middleware.py


示例14: test_thrashing

    def test_thrashing(self):
        settings.THRASHING_LIMIT = 10
        settings.THRASHING_TIMEOUT = 60
        
        Message.objects.all().delete()
        GroupedMessage.objects.all().delete()
        
        message_id = None
        for i in range(0, 10):
            this_message_id = get_client().create_from_text('hi')
            self.assertTrue(this_message_id is not None)
            self.assertNotEquals(this_message_id, message_id)
            message_id = this_message_id

        for i in range(0, 40):
            this_message_id = get_client().create_from_text('hi')
            self.assertEquals(this_message_id, message_id)
        
        self.assertEquals(Message.objects.count(), settings.THRASHING_LIMIT)
开发者ID:olarcheveque,项目名称:django-sentry,代码行数:19,代码来源:tests.py


示例15: main_thread_terminated

def main_thread_terminated():
    client = get_client()
    if isinstance(client, AsyncSentryClient):
        size = client.queue.qsize()
        if size:
            print "Sentry attempts to send %s error messages" % size
            print "Waiting up to %s seconds" % SENTRY_WAIT_SECONDS
            if os.name == 'nt':
                print "Press Ctrl-Break to quit"
            else:
                print "Press Ctrl-C to quit"
            client.stop(timeout = SENTRY_WAIT_SECONDS)
开发者ID:Torkn,项目名称:django-sentry,代码行数:12,代码来源:async.py


示例16: emit

    def emit(self, record):
        from sentry.client.models import get_client
        from sentry.client.middleware import SentryLogMiddleware

        # Fetch the request from a threadlocal variable, if available
        request = getattr(SentryLogMiddleware.thread, 'request', None)

        self.format(record)

        # Avoid typical config issues by overriding loggers behavior
        if record.name == 'sentry.errors':
            print >> sys.stderr, "Recursive log message sent to SentryHandler"
            print >> sys.stderr, record.message
            return

        self.format(record)
        try:
            get_client().create_from_record(record, request=request)
        except Exception:
            print >> sys.stderr, "Top level Sentry exception caught - failed creating log record"
            print >> sys.stderr, record.msg
            return
开发者ID:Torkn,项目名称:django-sentry,代码行数:22,代码来源:handlers.py


示例17: test_broken_cache

    def test_broken_cache(self):
        from django.core.cache import cache
        add_func = cache.add
        cache.add = lambda: False
        
        client = get_client()
        
        settings.THRASHING_LIMIT = 10
        settings.THRASHING_TIMEOUT = 60
        
        result = client.check_throttle('foobar')

        self.assertEquals(result, (False, None))
        
        cache.add = add_func
开发者ID:olarcheveque,项目名称:django-sentry,代码行数:15,代码来源:tests.py


示例18: testCreateFromRecordNoneExcInfo

 def testCreateFromRecordNoneExcInfo(self):
     # sys.exc_info can return (None, None, None) if no exception is being
     # handled anywhere on the stack. See:
     #  http://docs.python.org/library/sys.html#sys.exc_info
     client = get_client()
     record = logging.LogRecord(
         'foo', 
         logging.INFO, 
         pathname=None,
         lineno=None,
         msg='test',
         args=(),
         exc_info=(None, None, None),
     )
     message = client.create_from_record(record)
     self.assertEquals('test', message.message)
开发者ID:kbussell,项目名称:django-sentry,代码行数:16,代码来源:tests.py


示例19: test_get_client

 def test_get_client(self):
     from sentry.client.log import LoggingSentryClient
     self.assertEquals(get_client().__class__, SentryClient)
     self.assertEquals(get_client(), get_client())
 
     conf.CLIENT = 'sentry.client.log.LoggingSentryClient'
     
     self.assertEquals(get_client().__class__, LoggingSentryClient)
     self.assertEquals(get_client(), get_client())
 
     conf.CLIENT = 'sentry.client.base.SentryClient'
开发者ID:carmi,项目名称:django-sentry,代码行数:11,代码来源:tests.py


示例20: test_logging_client

    def test_logging_client(self):
        settings.CLIENT = 'sentry.client.log.LoggingSentryClient'
        
        client = get_client()
        
        _foo = {'': None}
        
        class handler(logging.Handler):
            def emit(self, record):
                _foo[''] = record

        logger = client.logger
        logger.addHandler(handler())
        
        self.assertRaises(Exception, self.client.get, reverse('sentry-raise-exc'))
        
        self.assertEquals(_foo[''].getMessage(), 'view exception')
        self.assertEquals(_foo[''].levelno, client.default_level)
        self.assertEquals(_foo[''].class_name, 'Exception')
开发者ID:klipstein,项目名称:django-sentry,代码行数:19,代码来源:tests.py



注:本文中的sentry.client.models.get_client函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python constants.LOG_LEVELS类代码示例发布时间:2022-05-27
下一篇:
Python default_cache.set函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap