seth vidal wrote:
On Tue, 2006-12-19 at 11:24 -0500, Jeremy Katz wrote:
On Mon, 2006-12-18 at 21:29 +0100, Terje Rosten wrote:
+    app = os.path.basename(sys.argv[0])
+    if app == 'yum':
+ app = 'yum-cli'
Personally, I'd prefer if this were done by an explicit call from the
app and we just leave out the app if it's not specified.


+1

-sv

I have worked a little with Terje's patch and modified it so the application can be set by a function call.

I have add the following code in yumex to test it.

       # Try to set the Logging application shown in syslog
       try:
           yum.logginglevels.setLoggingApp('yumex')
       except:
           pass

if i install something in yumex, it looks like this.
Dec 22 14:33:41 localhost yum(yumex): Updated: mplayerplug-in.i386 3.35-1.lvn6

Tim


### Eclipse Workspace Patch 1.0
#P yum
Index: yum/logginglevels.py
===================================================================
RCS file: /home/groups/yum/cvs//yum/yum/logginglevels.py,v
retrieving revision 1.8
diff -u -r1.8 logginglevels.py
--- yum/logginglevels.py        19 Dec 2006 01:44:01 -0000      1.8
+++ yum/logginglevels.py        22 Dec 2006 13:34:48 -0000
@@ -96,7 +96,8 @@
     logging.basicConfig()
 
     plainformatter = logging.Formatter("%(message)s")
-        
+    syslogformatter = logging.Formatter("yum : %(message)s")
+    
     console_stdout = logging.StreamHandler(sys.stdout)
     console_stdout.setFormatter(plainformatter)
     verbose = logging.getLogger("yum.verbose")
@@ -114,11 +115,12 @@
     filelogger.propagate = False
 
     log_dev = '/dev/log'
+    global syslog
     syslog = None
     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:
@@ -143,3 +145,10 @@
             filelogger.addHandler(filehandler)
         except IOError:
             logging.getLogger("yum").critical('Cannot open logfile %s', 
logfile)
+
+def setLoggingApp(app):
+    global syslog
+    if syslog:
+        syslogformatter = logging.Formatter("yum(%s): "% (app,) + 
"%(message)s")
+        syslog.setFormatter(syslogformatter)
+                    
\ No newline at end of file
_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to