-
-
Save anonymous/6117774 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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