SHARE
TWEET

Untitled

a guest Jul 17th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import logging
  2. NOTICE = 25
  3. logging.addLevelName(NOTICE, "NOTICE")
  4. def notice(self, message, *args, **kws):
  5.     if self.isEnabledFor(NOTICE):
  6.         self._log(NOTICE, message, args, **kws)
  7. logging.Logger.notice = notice
  8.      
  9. spam (5)
  10.  verbose (15)
  11.  notice (25)
  12.  success (35)
  13.      
  14. import logging
  15. def _custom_log_level(level_no, level_name):
  16.     logging.addLevelName(level_no, level_name)
  17.     def proxy_level(self, message, *args, **kwargs):
  18.         if self.isEnabledFor(level_no):
  19.             self._log(level_no, message, *args, **kwargs)
  20.     return proxy_level
  21.      
  22. logging.Logger.notice = _custom_log_level(25, 'NOTICE')
  23. logging.Logger.spam = _custom_log_level(5, 'SPAM')
  24.      
  25. verbose = _custom_log_level(15, 'VERBOSE')
  26.    verbose.__name__ = 'verbose'
  27.    logging.Logger.verbose = verbose
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top