# -*- coding: utf-8 -*-
# @Time : 2018/9/19 14:45
# @Author : cxa
# @File : decorator.py
# @Software: PyCharm
from common.logger import logger
import time
from functools import wraps
import traceback
def decorator(m):
def _deco(func):
@wraps(func)
def timer(*args, **kwargs):
try:
start = time.time()
func(*args, **kwargs)
end = time.time()
print(dir(func))
logger.info(f"{m} file's {func.__name__} method is running,cost time{end-start}s")
except Exception as e:
logger.error(
f"{m} file's {func.__name__} method ,is error,there are details:{traceback.format_exc()}")
return timer
return _deco