Winand

Untitled

Jan 12th, 2013
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. from logging import debug as dbg, info as inf, warn as wrn, error as err, fatal as ftl
  2. from settings import LOG_LEVEL
  3.  
  4. def __genLogWrapper(f):
  5.     def logwith(*l):
  6.         calframe = inspect.getouterframes(inspect.currentframe())
  7.         if len(calframe)>1:
  8.             frame=calframe[1]
  9.             mod=os.path.splitext(os.path.basename(frame[1]))[0]
  10.             func="."+frame[3] if frame[3] != "<module>" else ""
  11.         f(" ".join([str(i) for i in (mod+func+":"+str(frame[2])+">\n",)+l]))
  12.     return logwith
  13.    
  14. debug, info, warn, error, fatal=map(__genLogWrapper, [dbg, inf, wrn, err, ftl])
Advertisement
Add Comment
Please, Sign In to add comment