%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/log/handlers/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/log/handlers/sentry_mod.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddl	m
Z
y&ddlZddlm
Z
eZWnek
r�eZnXeje�ZiZiZdZd�Zd�Zdd	�ZdS(
uK
    Sentry Logging Handler
    ======================

    .. versionadded:: 0.17.0

    This module provides a `Sentry`_ logging handler. Sentry is an open source
    error tracking platform that provides deep context about exceptions that
    happen in production. Details about stack traces along with the context
    variables available at the time of the exception are easily browsable and
    filterable from the online interface. For more details please see
    `Sentry`_.

    .. admonition:: Note

        The `Raven`_ library needs to be installed on the system for this
        logging handler to be available.

    Configuring the python `Sentry`_ client, `Raven`_, should be done under the
    ``sentry_handler`` configuration key. Additional `context` may be provided
    for corresponding grain item(s).
    At the bare minimum, you need to define the `DSN`_. As an example:

    .. code-block:: yaml

        sentry_handler:
          dsn: https://pub-key:secret-key@app.getsentry.com/app-id


    More complex configurations can be achieved, for example:

    .. code-block:: yaml

        sentry_handler:
          servers:
            - https://sentry.example.com
            - http://192.168.1.1
          project: app-id
          public_key: deadbeefdeadbeefdeadbeefdeadbeef
          secret_key: beefdeadbeefdeadbeefdeadbeefdead
          context:
            - os
            - master
            - saltversion
            - cpuarch
            - ec2.tags.environment

    .. admonition:: Note

        The ``public_key`` and ``secret_key`` variables are not supported with
        Sentry > 3.0. The `DSN`_ key should be used instead.

    All the client configuration keys are supported, please see the
    `Raven client documentation`_.

    The default logging level for the sentry handler is ``ERROR``. If you wish
    to define a different one, define ``log_level`` under the
    ``sentry_handler`` configuration key:

    .. code-block:: yaml

      sentry_handler:
        dsn: https://pub-key:secret-key@app.getsentry.com/app-id
        log_level: warning


    The available log levels are those also available for the salt ``cli``
    tools and configuration; ``salt --help`` should give you the required
    information.


    Threaded Transports
    -------------------

    Raven's documents rightly suggest using its threaded transport for
    critical applications. However, don't forget that if you start having
    troubles with Salt after enabling the threaded transport, please try
    switching to a non-threaded transport to see if that fixes your problem.



    .. _`DSN`: https://raven.readthedocs.io/en/latest/config/index.html#the-sentry-dsn
    .. _`Sentry`: https://getsentry.com
    .. _`Raven`: https://raven.readthedocs.io
    .. _`Raven client documentation`: https://raven.readthedocs.io/en/latest/config/index.html#client-arguments
i(tabsolute_importtprint_functiontunicode_literalsN(t
LOG_LEVELS(t
SentryHandlerusentrycC@sttkrtStS(N(t	HAS_RAVENtTruet__virtualname__tFalse(((s@/usr/lib/python2.7/site-packages/salt/log/handlers/sentry_mod.pyt__virtual__rsc@satjjt�}tjjt�}dtkrAtjd�tSi}td�}|dk	r�yoddl
m}m}ddl
m}||�}||�}|j|j�s�tdj|j���nWq�tk
r�}	tjd|	�q�Xn|sexed#D]Z}
t|
�}|dkrB|
|krBtjd
|
�dS|dkrTqn|||
<qWn|ji
td�d6td�d6tdd$�d6tdd%�d6td�d6td�d6td�d6tdd�d6td�d6|d6�tj|�}td�}
i}|
dk	r�xV|
D]N}y||}Wn$tk
retjd|�q+nX|r+|||<q+q+W|r�|jji|d6�q�ny�t|�}tdd�}|rg|D]}tj|�^q��dtf�fd��Y}|j|��n|jt tdd ��|SWn&tk
r\}	tjd!d"t!�nXdS(&u$
    sets up the sentry handler
    usentry_handleru6No 'sentry_handler' key was found in the configurationudsni(tTransportRegistrytdefault_transports(turlparseu"Unsupported Sentry DSN scheme: {0}u8Raven failed to parse the configuration provided DSN: %suprojectuserversu
public_keyu
secret_keyu~The required 'sentry_handler' configuration key, '%s', is not properly configured. Not configuring the sentry logging handler.Nusiteunameu
exclude_pathsu
include_pathsulist_max_lengthustring_max_lengthuauto_log_stacksutimeoutiu
processorsucontextu$Sentry tag '%s' not found in grains.utagsuexclude_patternstFilterExcludedMessagesc@seZe�fd��ZRS(c@s'|j��t�fd��D��S(Nc3@s|]}|j��VqdS(N(tsearch(t.0tregex(tm(s@/usr/lib/python2.7/site-packages/salt/log/handlers/sentry_mod.pys	<genexpr>�s(t
getMessagetany(trecord(tfilter_regexes(Rs@/usr/lib/python2.7/site-packages/salt/log/handlers/sentry_mod.pytfilter�s(t__name__t
__module__tstaticmethodR((R(s@/usr/lib/python2.7/site-packages/salt/log/handlers/sentry_mod.pyR
�su	log_leveluerroru*Failed to setup the sentry logging handlertexc_info(uprojectuserversu
public_keyu
secret_key((("tsalttloadertgrainst__opts__tminion_modstlogtdebugRtget_config_valuetNonetraven.transportR
Rtraven.utils.urlparseRtsupported_schemetschemet
ValueErrortformattinfotupdatetraventClienttKeyErrortcontexttmergeRtretcompiletobjectt	addFiltertsetLevelRR(t
__grains__t__salt__toptionstdsnR
RRttransport_registryturltexctkeytconfig_valuetclientR/tcontext_dictttagt	tag_valuethandlertexclude_patternstpatternR
((Rs@/usr/lib/python2.7/site-packages/salt/log/handlers/sentry_mod.pytsetup_handlersxs�

	







"cC@stdj||�S(u?
    returns a configuration option for the sentry_handler
    usentry_handler(Rtget(tnametdefault((s@/usr/lib/python2.7/site-packages/salt/log/handlers/sentry_mod.pyR"�s(t__doc__t
__future__RRRtloggingR1tsalt.loaderRtsalt.logRR,traven.handlers.loggingRRRtImportErrorRt	getLoggerRR R6R7RR	RFR#R"(((s@/usr/lib/python2.7/site-packages/salt/log/handlers/sentry_mod.pyt<module>Ws$


		v

Zerion Mini Shell 1.0