Current logging to syslog appear as

 Dec 12 08:09:38 hostname Updated: openssh-server.x86_64 4.3p2-14.fc6

It't nice, however it's common to add a tag, in this case yum, like
this:

 Dec 12 08:09:38 hostname yum: Updated: openssh-server.x86_64 4.3p2-14.fc6

This way it's also very easy for e.g. logwatch to create a nice daily
yum report.

The patch is simple:


Index: yum/logginglevels.py
===================================================================
RCS file: /cvsroot/yum/cvs/yum/yum/logginglevels.py,v
retrieving revision 1.7
diff -u -r1.7 logginglevels.py
--- yum/logginglevels.py        25 Oct 2006 06:08:31 -0000      1.7
+++ yum/logginglevels.py        13 Dec 2006 20:12:44 -0000
@@ -96,6 +96,7 @@
     logging.basicConfig()
 
     plainformatter = logging.Formatter("%(message)s")
+    syslogformatter = logging.Formatter("yum: %(message)s")
         
     console_stdout = logging.StreamHandler(sys.stdout)
     console_stdout.setFormatter(plainformatter)
@@ -118,7 +119,7 @@
     if os.path.exists(log_dev):
         try:
             syslog = logging.handlers.SysLogHandler(log_dev)
-            syslog.setFormatter(plainformatter)
+            syslog.setFormatter(syslogformatter)
             filelogger.addHandler(syslog)
         except socket.error:
             if syslog is not None:


 - Terje

Index: yum/logginglevels.py
===================================================================
RCS file: /cvsroot/yum/cvs/yum/yum/logginglevels.py,v
retrieving revision 1.7
diff -u -r1.7 logginglevels.py
--- yum/logginglevels.py	25 Oct 2006 06:08:31 -0000	1.7
+++ yum/logginglevels.py	13 Dec 2006 20:21:58 -0000
@@ -96,6 +96,7 @@
     logging.basicConfig()
 
     plainformatter = logging.Formatter("%(message)s")
+    syslogformatter = logging.Formatter("yum: %(message)s")
         
     console_stdout = logging.StreamHandler(sys.stdout)
     console_stdout.setFormatter(plainformatter)
@@ -118,7 +119,7 @@
     if os.path.exists(log_dev):
         try:
             syslog = logging.handlers.SysLogHandler(log_dev)
-            syslog.setFormatter(plainformatter)
+            syslog.setFormatter(syslogformatter)
             filelogger.addHandler(syslog)
         except socket.error:
             if syslog is not None:
_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to