Skip to content

Commit

Permalink
Add timing level info
Browse files Browse the repository at this point in the history
  • Loading branch information
DinhNgocAnh committed May 2, 2020
1 parent 1671c68 commit b9b7c43
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion apps/common/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,15 @@ def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
level = "Info"

print('Time it: %r (%r, %r) %2.2f sec' % (method.__name__, args, kw, te - ts))
if 1 <= te - ts < 5:
level = "Warning"

if te - ts >= 5:
level = "Critical"

print('[%r] Time it: %r (%r, %r) %2.2f sec' % (level, method.__name__, args, kw, te - ts))
return result

return timed
Expand Down

0 comments on commit b9b7c43

Please sign in to comment.