X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=logging.py;h=ae8ee6f2c81b7a895cfb9d8020243f8affe34016;hb=5fa4d7d8e679f5e77d58d0378861c8050aae4864;hp=5aba74dfd6520ed457e287015492dcd2d21ca517;hpb=1974c4d06ace089e597e8a2aef3ac1122a1c8452;p=dak.git diff --git a/logging.py b/logging.py index 5aba74df..ae8ee6f2 100644 --- a/logging.py +++ b/logging.py @@ -1,6 +1,8 @@ +#!/usr/bin/env python + # Logging functions -# Copyright (C) 2001 James Troup -# $Id: logging.py,v 1.1 2001-07-07 03:59:45 troup Exp $ +# Copyright (C) 2001, 2002 James Troup +# $Id: logging.py,v 1.3 2002-10-16 02:47:32 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -15,11 +17,11 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - + ################################################################################ -import os, pwd, string, time -import utils +import os, pwd, time; +import utils; ################################################################################ @@ -34,15 +36,15 @@ class Logger: self.Cnf = Cnf; self.program = program; # Create the log directory if it doesn't exist - logdir = Cnf["Dir::LogDir"]; + logdir = Cnf["Dir::Log"]; if not os.path.exists(logdir): umask = os.umask(00000); os.makedirs(logdir, 02775); # Open the logfile - logfilename = "%s/%s" % (logdir, time.strftime("%Y-%m", time.localtime(time.time()))); + logfilename = "%s/%s" % (logdir, time.strftime("%Y-%m")); logfile = utils.open_file(logfilename, 'a'); # Seek to the end of the logfile - logfile.seek(0,2); + logfile.seek(0,2); self.logfile = logfile; # Log the start of the program user = pwd.getpwuid(os.getuid())[0]; @@ -52,12 +54,12 @@ class Logger: "Log an event" # Prepend the timestamp and program name details.insert(0, self.program); - timestamp = time.strftime("%Y%m%d%H%M%S", time.localtime(time.time())); + timestamp = time.strftime("%Y%m%d%H%M%S"); details.insert(0, timestamp); # Force the contents of the list to be string.join-able details = map(str, details); # Write out the log in TSV - self.logfile.write(string.join(details, '~')+'\n'); + self.logfile.write("~".join(details)+'\n'); # Flush the output to enable tail-ing self.logfile.flush();