Last active
June 6, 2016 18:25
-
-
Save mmasztalerczuk/e04c6c8c0572c59bf4519e5ca13cbf2d 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 | |
def createLogger(name): | |
logger = logging.getLogger(name) | |
hdlr = logging.FileHandler('test.log') | |
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') | |
hdlr.setFormatter(formatter) | |
logger.addHandler(hdlr) | |
logger.setLevel(logging.DEBUG) | |
return logger | |
class A(): | |
def __init__(self): | |
self.logger = createLogger("A") | |
self.logger.info("Hello A!") | |
class B(): | |
def __init__(self): | |
self.logger = createLogger("B") | |
self.logger.info("Hello B!") | |
a = A() | |
b = B() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment