diff options
| author | bwarsaw | 2002-10-21 21:33:40 +0000 |
|---|---|---|
| committer | bwarsaw | 2002-10-21 21:33:40 +0000 |
| commit | 77856d4178c735d1a870aef060142877bc685be7 (patch) | |
| tree | 7a7c86b684c7c56cd5816c6889e0fcd0566b01f8 /Mailman/Logging/Utils.py | |
| parent | ba83b4dfe8ee7d5c643870d7c035ec4f160dbc23 (diff) | |
| download | mailman-77856d4178c735d1a870aef060142877bc685be7.tar.gz mailman-77856d4178c735d1a870aef060142877bc685be7.tar.zst mailman-77856d4178c735d1a870aef060142877bc685be7.zip | |
Diffstat (limited to 'Mailman/Logging/Utils.py')
| -rw-r--r-- | Mailman/Logging/Utils.py | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/Mailman/Logging/Utils.py b/Mailman/Logging/Utils.py index d70e2a424..ef119fb09 100644 --- a/Mailman/Logging/Utils.py +++ b/Mailman/Logging/Utils.py @@ -4,14 +4,14 @@ # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software +# along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. import sys @@ -24,27 +24,29 @@ def _logexc(logger=None, msg=''): sys.__stderr__.write('Original log message:\n%s\n' % msg) -def LogStdErr(category, label, manual_reprime=1, tee_to_stdout=1): - """Establish a StampedLogger on sys.stderr if possible. sys.stdout - also gets stderr output, using a MultiLogger. +def LogStdErr(category, label, manual_reprime=1, tee_to_real_stderr=1): + """Establish a StampedLogger on sys.stderr if possible. - Returns the MultiLogger if successful, None otherwise.""" - import sys + If tee_to_real_stderr is true, then the real standard error also gets + output, via a MultiLogger. + + Returns the MultiLogger if successful, None otherwise. + """ from StampedLogger import StampedLogger from MultiLogger import MultiLogger try: - sys.stderr = StampedLogger(category, - label=label, - manual_reprime=manual_reprime, - nofail=0) - if tee_to_stdout: - if hasattr(sys, '__stdout__'): - stdout = sys.__stdout__ + logger = StampedLogger(category, + label=label, + manual_reprime=manual_reprime, + nofail=0) + if tee_to_real_stderr: + if hasattr(sys, '__stderr__'): + stderr = sys.__stderr__ else: - stdout = sys.stdout - multi = MultiLogger(stdout, sys.stderr) - sys.stderr = multi + stderr = sys.stderr + logger = MultiLogger(stderr, logger) + sys.stderr = logger return sys.stderr except IOError: return None - + |
