Skip to content

Instantly share code, notes, and snippets.

@affo
Last active February 9, 2016 17:18
Show Gist options
  • Save affo/5848ab5e5140fab03dc7 to your computer and use it in GitHub Desktop.
Save affo/5848ab5e5140fab03dc7 to your computer and use it in GitHub Desktop.
Python module for logging
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)
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