Created
October 9, 2012 18:45
-
-
Save SecurityForUs/3860639 to your computer and use it in GitHub Desktop.
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
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