Permalink
Browse files

Added timestamps to LT logs, cleaner logfile names

  • Loading branch information...
1 parent 614966a commit ca3a81a9853e28a588812103d994cae5ec15de12 @labisso labisso committed Nov 15, 2010
Showing with 4 additions and 2 deletions.
  1. +4 −2 lantorrent/pylantorrent/__init__.py
@@ -62,7 +62,8 @@ def __init__(self):
except:
emsg = "failed to load %s, using defaults" % (ini_file)
log(logging.WARNING, emsg, traceback)
- logging.basicConfig(filename=self.logfile, level=self.log_level)
+ logging.basicConfig(filename=self.logfile, level=self.log_level,
+ format="%(asctime)s - %(levelname)s - %(message)s")
log(logging.WARNING, "logging to %s at %d" % (self.logfile, self.log_level))
def set_defaults(self):
@@ -83,7 +84,8 @@ def load_settings(self, ini_file):
s = SafeConfigParser()
s.readfp(open(ini_file, "r"))
self.pw = s.get("security", "password")
- self.logfile = s.get("log", "file").replace("@LANTORRENT_HOME@", self.lt_home).replace("@PGM@", os.path.basename(sys.argv[0]))
+ prog = os.path.splitext(os.path.basename(sys.argv[0]))[0]
+ self.logfile = s.get("log", "file").replace("@LANTORRENT_HOME@", self.lt_home).replace("@PGM@", prog)
try:
log_level_str = s.get("log", "level")
self.log_level = log_levels[log_level_str]

0 comments on commit ca3a81a

Please sign in to comment.