示例#1
0
        def deprecated_function(*args, **kwargs):
            message = 'Function "{function_name}" is deprecated{warning_message}'.format(
                function_name=fn.__name__,
                warning_message=': {}'.format(self.warning) if self.warning is not None else '')

            try:
                log(message, WARN)
            except:
                print message

            return fn(*args, **kwargs)
示例#2
0
        def timed(*args, **kwargs):
            ts = time.time()
            return_val = fn(*args, **kwargs)
            te = time.time()

            elapsed = round(te - ts, 4)
            message = 'Function "{}" elapsed time: {} seconds'.format(fn.__name__, elapsed)

            if self.logger is not None:
                print message
                self.logger.info(message)
            else:
                try:
                    print message
                    log(message)
                except:
                    print message

            return return_val
        def timed(*args, **kwargs):
            ts = time.time()
            return_val = fn(*args, **kwargs)
            te = time.time()

            elapsed = round(te - ts, 4)
            message = 'Function "{}" elapsed time: {} seconds'.format(
                fn.__name__, elapsed)

            if self.logger is not None:
                print(message)
                self.logger.info(message)
            else:
                try:
                    print(message)
                    log(message)
                except:
                    print(message)

            return return_val