Skip to content

Instantly share code, notes, and snippets.

@SecurityForUs
Created October 9, 2012 18:45
Show Gist options
  • Save SecurityForUs/3860639 to your computer and use it in GitHub Desktop.
Save SecurityForUs/3860639 to your computer and use it in GitHub Desktop.
class ClassBase:
def __init__(self, log_name, client = True):
try:
self.conf
except:
self.conf = Config()
try:
self.log
except:
format = logging.Formatter("[%(asctime)s] - %(levelname)s in %(name)s: %(message)s")
if client:
flog = logging.FileHandler(filename="logs/client.log")
else:
flog = logging.FileHandler(filename="logs/updater.log")
flog.setFormatter(format)
self.log = logging.getLogger(log_name)
self.log.addHandler(flog)
# First we see if the user specifies a log level. If not, we set it to error logs.
try:
conf_level = str(self.conf['system']['log_level']).lower()
LEVELS = { "debug" : logging.DEBUG, "info" : logging.INFO, "warning" : logging.WARNING, "error" : logging.ERROR, "critical" : logging.CRITICAL}
self.log.setLevel(LEVELS[conf_level])
except:
self.log.setLevel(logging.ERROR)
class ShitBalls(ClassBase):
def __init__(self):
ClassBase.__init__(self, "shitballs")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment