B Y%@sdZddlmZddlmZmZmZddlmZddl m Z ddl Z ddl m Z ddlmZe eZGd d d e ZGd d d eZdS) z raven.contrib.zope ~~~~~~~~~~~~~~~~~~ :copyright: (c) 2010-2013 by the Sentry Team, see AUTHORS for more details. :license: BSD, see LICENSE for more details. )absolute_import)getouterframes currentframegetinnerframes) SentryHandler)FactoryN)nobody)iter_stack_framesc@s$eZdZddZddZddZdS)ZopeSentryHandlerFactorycCs|jjS)N)sectionlevel)selfrL/opt/alt/python37/lib/python3.7/site-packages/raven/contrib/zope/__init__.pygetLevelsz!ZopeSentryHandlerFactory.getLevelcCstf|jjS)N)ZopeSentryHandlerr __dict__)r rrrcreateszZopeSentryHandlerFactory.createcCst|||_dS)N)r__init__r )r r rrrrs z!ZopeSentryHandlerFactory.__init__N)__name__ __module__ __qualname__rrrrrrrr sr cs4eZdZdZfddZddZfddZZS)rz Zope unfortunately eats the stack trace information. To get the stack trace information and other useful information from the request object, this class looks into the different stack frames when the emit method is invoked. cs.tt|j|||dtj}||dS)Nr )superrrgetloggingERRORsetLevel)r argskwr ) __class__rrr*szZopeSentryHandler.__init__cCs|jdkp|jd S)Nraven)z sentry.errorszraven.)name startswith)r recordrrr can_record/s zZopeSentryHandler.can_recordc s |jtjkr||rd}d}xttD]}|d}|s|jdd}|s|jdd}yt|dd}Wnt k rd}YnX|s|jdd}t |dsd}|r.|r.Pq.W|r||_ t t |d|_|ry|j}|jd|j}|j|t|j||j|jdd|d } d | d krZd | d krZ| d d | d d <d | d krx| d d | d<t|d| |dd} | dk r| tkr| | dpdd} ni} t|d| Wn(ttfk rtjdddYnXtt |!|S)Nrrequestr exc_info __getitem__Z REMOTE_ADDR)headersurlmethodhostdataZHTTP_USER_AGENTr*z User-AgentZ QUERY_STRINGZ query_stringZAUTHENTICATED_USERemail)idr/userz#Could not extract data from requestT)r&)"levelnorrr$rrf_localsrgetattr RuntimeErrorhasattrr&r rstackstdintellseekreaddictenvironZgetURLr,setattrrZgetId getPropertyAttributeErrorKeyErrorloggerwarningrremit) r r#r%r&Z frame_infoframeviewZbody_posbodyhttpr1Z user_dict)rrrrD5s`         zZopeSentryHandler.emit)rrr__doc__rr$rD __classcell__rr)rrr"s r)rI __future__rinspectrrrZraven.handlers.loggingrZ!ZConfig.components.logger.factoryrrZAccessControl.usersrZraven.utils.stacksr getLoggerrrBr rrrrrs