Skip to content
Browse files

Include log level name in logs. Add AIClient._setup_logging

  • Loading branch information...
1 parent ee501b1 commit ea91c6fb1d5b83b725bf33f0ccc26e9fd135450c @dripton committed Aug 9, 2012
Showing with 10 additions and 4 deletions.
  1. +2 −1 slugathon/ai/AIClient.py
  2. +2 −1 slugathon/gui/Connect.py
  3. +6 −2 slugathon/net/Server.py
View
3 slugathon/ai/AIClient.py
@@ -84,7 +84,8 @@ def _setup_logging(self):
log_observer = log.PythonLoggingObserver()
log_observer.start()
formatter = logging.Formatter(
- "%(asctime)s %(filename)s %(funcName)s %(lineno)d %(message)s")
+ "%(asctime)s %(levelname)s %(filename)s %(funcName)s %(lineno)d "
+ "%(message)s")
file_handler = logging.FileHandler(filename=self.log_path)
file_handler.setFormatter(formatter)
logging.getLogger().addHandler(file_handler)
View
3 slugathon/gui/Connect.py
@@ -111,7 +111,8 @@ def __init__(self, playername, password, server_name, server_port,
log_observer = log.PythonLoggingObserver()
log_observer.start()
formatter = logging.Formatter(
- "%(asctime)s %(filename)s %(funcName)s %(lineno)d %(message)s")
+ "%(asctime)s %(levelname)s %(filename)s %(funcName)s %(lineno)d "
+ "%(message)s")
if log_path:
file_handler = logging.FileHandler(filename=log_path)
file_handler.setFormatter(formatter)
View
8 slugathon/net/Server.py
@@ -49,16 +49,20 @@ def __init__(self, no_passwd, passwd_path, port, log_path):
self.results = Results.Results()
# {game_name: set(ainame) we're waiting for
self.game_to_waiting_ais = {}
+ self._setup_logging(log_path)
+ def _setup_logging(self, log_path):
log_observer = log.PythonLoggingObserver()
log_observer.start()
formatter = logging.Formatter(
- "%(asctime)s %(filename)s %(funcName)s %(lineno)d %(message)s")
+ "%(asctime)s %(levelname)s %(filename)s %(funcName)s %(lineno)d "
+ "%(message)s")
if not log_path:
logdir = os.path.join(TEMPDIR, "slugathon")
if not os.path.exists(logdir):
os.makedirs(logdir)
- log_path = os.path.join(logdir, "slugathon-server-%d.log" % port)
+ log_path = os.path.join(logdir, "slugathon-server-%d.log" %
+ self.port)
file_handler = RotatingFileHandler(filename=log_path,
maxBytes=100000000, backupCount=99)
file_handler.setFormatter(formatter)

0 comments on commit ea91c6f

Please sign in to comment.
Something went wrong with that request. Please try again.