Last active
February 9, 2016 17:18
-
-
Save affo/5848ab5e5140fab03dc7 to your computer and use it in GitHub Desktop.
Python module for logging
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 ConfigParser as cp | |
CONFIG_FILE = 'project.conf' | |
_CONF = cp.ConfigParser() | |
_CONF.readfp(open(CONFIG_FILE)) | |
def get(opt, section='DEFAULT'): | |
return _CONF.get(section, opt) |
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 | |
logging.basicConfig(filename='log.log', level=logging.DEBUG) | |
_loggers = {} | |
def get(module_name): | |
global _loggers | |
logger = _loggers.get(module_name, None) | |
if logger is None: | |
logger = logging.getLogger(module_name) | |
_loggers[module_name] = logger | |
return logger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment