# -*- coding: utf-8 -*-import logging def singleton(cls): instance = {} def _singleton(*args, **kw): if cls not in instance: instance[cls] = cls(*args, **kw) return instance[cls] return _singleton @singleton class TkLog(object): """docstring for ClassName""" def __init__(self): FORMAT = '%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s' logging.basicConfig( format=FORMAT, datefmt='%a, %d %b %Y %H:%M:%S', filename='/root/test/myapp.log', filemode='w') self.logger = logging.getLogger('icheer') def debug(self, data): self.logger.debug(data) def info(self, data): self.logger.info(data) def warn(self, data): self.logger.warning(data) def error(self, data): self.logger.error(data) def critical(self, data): self.logger.critical(data) def exception(self, data): self.logger.exception(data) def set_log_level(self, level): self.log_level = level self.logger.setLevel(self.log_level)