Skip to content

Instantly share code, notes, and snippets.

@mmasztalerczuk
Created June 6, 2016 19:08
Show Gist options
  • Save mmasztalerczuk/e00c7ebaee101849e4a28652c6a3bc55 to your computer and use it in GitHub Desktop.
Save mmasztalerczuk/e00c7ebaee101849e4a28652c6a3bc55 to your computer and use it in GitHub Desktop.
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(self.__class__.__name__)
self.logger.info("Elo " + self.__class__.__name__)
class B(A):
def __init__(self):
super(B, self).__init__()
a = A()
b = B()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment