Skip to content

Instantly share code, notes, and snippets.

/-

Created July 30, 2013 22:52
Show Gist options
  • Save anonymous/6117774 to your computer and use it in GitHub Desktop.
Save anonymous/6117774 to your computer and use it in GitHub Desktop.
import logging
import logging.handlers
log_file = logging.getLogger('f')
log_watch = logging.getLogger('w')
log_rotate_bytes = logging.getLogger('r')
log_time = logging.getLogger('t')
fh = logging.FileHandler('f.log')
wh = logging.handlers.WatchedFileHandler('w.log')
rh = logging.handlers.RotatingFileHandler('r.log', maxBytes=1000, backupCount=5)
th = logging.handlers.TimedRotatingFileHandler('t.log', when='s', interval=1,
backupCount=5)
log_file.addHandler(fh)
log_watch.addHandler(wh)
log_rotate_bytes.addHandler(rh)
log_time.addHandler(th)
loggers = ('log_file', 'log_watch', 'log_rotate_bytes', 'log_time')
def log_me(logger):
logger.error("This is bad")
import timeit
for logger in loggers[2:]:
print logger
print(timeit.timeit("log_me({})".format(logger),
setup="from __main__ import log_me, " + logger))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment