Update of /cvsroot/mailman/mailman3/bin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28954

Modified Files:
        mailmanctl 
Log Message:
main(): Another attempt at daemon logging of exceptions.  Sigh.


Index: mailmanctl
===================================================================
RCS file: /cvsroot/mailman/mailman3/bin/mailmanctl,v
retrieving revision 3.1
retrieving revision 3.2
diff -u -d -r3.1 -r3.2
--- mailmanctl  20 Apr 2004 04:11:36 -0000      3.1
+++ mailmanctl  21 Apr 2004 03:23:23 -0000      3.2
@@ -361,14 +361,28 @@
         fp.flush()
         fp.close()
         # Close stdin, stdout, and stderr and point them at /dev/null.
-        # BAW: Actually, we want stdout and stderr to point at the
-        # mailman.error log file at critical level.
-##        os.close(0)
-##        sys.stdin = sys.__stdin__ = open('/dev/null')
-##        os.close(1)
-##        sys.stdout = sys.__stdout__ = open('/dev/null', 'w')
-##        os.close(2)
-##        sys.stderr = sys.__stderr__ = open('/dev/null', 'w')
+        os.close(0)
+        sys.stdin = sys.__stdin__ = open('/dev/null')
+        os.close(1)
+        os.close(2)
+        # We want to log all exception that occur in this daemon to a log
+        # file, but we can't use the mailman.error logger.  I don't know why,
+        # but such messages simply get lost.
+        class LogWrapper:
+            def __init__(self):
+                # This doesn't work
+                #self._log = logging.getLogger('mailman.error')
+                path = os.path.join(configuration.layout.logdir,
+                                    'mailmanctl.log')
+                self._fp = open(path, 'a')
+            def write(self, s):
+                # This doesn't work
+                #self._log.exception(s)
+                self._fp.write(s)
+                self._fp.flush()
+        daemonlog = LogWrapper()
+        sys.stderr = sys.__stderr__ = daemonlog
+        sys.stdout = sys.__stdout__ = daemonlog
         # Create a new session and become the session leader, but since we
         # won't be opening any terminal devices, don't do the ultra-paranoid
         # suggestion of doing a second fork after the setsid() call.


_______________________________________________
Mailman-checkins mailing list
[EMAIL PROTECTED]
Unsubscribe: http://mail.python.org/mailman/options/mailman-checkins/archive%40jab.org

Reply via email to