Last active
September 21, 2016 19:33
-
-
Save podhmo/056213a4cd51c2e611b963b36ae9cdbb to your computer and use it in GitHub Desktop.
This file contains 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 wrap | |
logger = logging.getLogger(__name__) | |
wlogger = wrap.LoggerWrapper(logger) | |
def hello(): | |
logger.info("hello") | |
def hello2(): | |
wlogger.info("hello") | |
def log_with_additional_info(message, *args, **kwargs): | |
logger.info("additional: {}".format(message), *args, **kwargs) | |
def hello3(): | |
log_with_additional_info("hello") |
This file contains 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 hello | |
format = "time:%(asctime)s\tlevel:%(levelname)s\tmsg:%(message)s\tlocation:%(pathname)s(%(lineno)s)\tfn:%(funcName)s" | |
logging.basicConfig(level=logging.DEBUG, format=format) | |
hello.hello() | |
hello.hello2() | |
hello.hello3() |
This file contains 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
class LoggerWrapper: | |
def __init__(self, logger): | |
self.logger = logger | |
def info(self, *args, **kwargs): | |
# do something | |
self.logger.info(*args, **kwargs) |
Author
podhmo
commented
Sep 21, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment