Exemplo n.º 1
0
Arquivo: log.py Projeto: cdminigun/st2
    def func_wrapper(*args, **kwargs):
        # Prefix extra keys with underscore
        if 'extra' in kwargs:
            kwargs['extra'] = prefix_dict_keys(dictionary=kwargs['extra'], prefix='_')

        try:
            return func(*args, **kwargs)
        except TypeError as e:
            # In some version of Python 2.7, logger.exception doesn't take any kwargs so we need
            # this hack :/
            # See:
            # - https://docs.python.org/release/2.7.3/library/logging.html#logging.Logger.exception
            # - https://docs.python.org/release/2.7.7/library/logging.html#logging.Logger.exception
            if 'got an unexpected keyword argument \'extra\'' in str(e):
                kwargs.pop('extra', None)
                return func(*args, **kwargs)
            raise e
Exemplo n.º 2
0
Arquivo: log.py Projeto: yetudada/st2
    def func_wrapper(*args, **kwargs):
        # Prefix extra keys with underscore
        if 'extra' in kwargs:
            kwargs['extra'] = prefix_dict_keys(dictionary=kwargs['extra'], prefix='_')

        try:
            return func(*args, **kwargs)
        except TypeError as e:
            # In some version of Python 2.7, logger.exception doesn't take any kwargs so we need
            # this hack :/
            # See:
            # - https://docs.python.org/release/2.7.3/library/logging.html#logging.Logger.exception
            # - https://docs.python.org/release/2.7.7/library/logging.html#logging.Logger.exception
            if 'got an unexpected keyword argument \'extra\'' in six.text_type(e):
                kwargs.pop('extra', None)
                return func(*args, **kwargs)
            raise e
Exemplo n.º 3
0
 def func_wrapper(*args, **kwargs):
     # Prefix extra keys with underscore
     if 'extra' in kwargs:
         kwargs['extra'] = prefix_dict_keys(dictionary=kwargs['extra'], prefix='_')
     return func(*args, **kwargs)
Exemplo n.º 4
0
 def func_wrapper(*args, **kwargs):
     # Prefix extra keys with underscore
     if 'extra' in kwargs:
         kwargs['extra'] = prefix_dict_keys(dictionary=kwargs['extra'],
                                            prefix='_')
     return func(*args, **kwargs)