pull in the www-register-wizard for myplc native.
[myplc.git] / mtail.py
index 1fb5b68..09e443f 100755 (executable)
--- a/mtail.py
+++ b/mtail.py
@@ -12,7 +12,7 @@ from optparse import OptionParser
 
 class mtail:
 
-    subversion_id = "$Id: mtail.py 571 2007-06-22 21:38:07Z thierry $"
+    subversion_id = "$Id$"
 
     default_time_format = "%H:%M:%S"
     
@@ -59,10 +59,13 @@ example:
 
        ### plc shortcuts
        if self.options.plc_mode:
+            # monitor all files in /var/log with some exceptions
            self.options.excludes.append('*access_log')
            self.options.excludes.append('*request_log')
            self.options.excludes.append('*.swp')
            self.args.append('/var/log')
+            # watch the postgresql logs as well
+            self.args.append('/var/lib/pgsql/data/pg_log')
 
        if self.options.verbose:
            print 'Version:',self.subversion_id
@@ -109,7 +112,10 @@ example:
                    self.files[filename]['size']=size
                elif size < offset:
                    self.show_file_when_size_decreased(filename,offset,size)
-               del self.files[filename]['old-file']
+                try:
+                    del self.files[filename]['old-file']
+                except:
+                    pass
            else:
                # enter file with current size
                # if we didn't set format yet, it's because we are initializing
@@ -136,7 +142,11 @@ example:
            print sys.argv[0],": WARNING : no file in scope"
            self.format="%s"
        else:
-           self.margin=max(*[len(f) for f in filenames])
+           if len(filenames)==1:
+                self.margin=len(filenames[0])
+            else:
+                # this stupidly fails when there's only 1 file
+                self.margin=max(*[len(f) for f in filenames])
            self.format="%%%ds"%self.margin
            if self.options.verbose:
                print 'Current set of files:',filenames