]> granicus.if.org Git - python/commitdiff
using log.warn for sys.stderr
authorTarek Ziadé <ziade.tarek@gmail.com>
Tue, 31 Mar 2009 20:48:31 +0000 (20:48 +0000)
committerTarek Ziadé <ziade.tarek@gmail.com>
Tue, 31 Mar 2009 20:48:31 +0000 (20:48 +0000)
Lib/distutils/cmd.py
Lib/distutils/log.py

index 012fca15b565d55d967438a06c4a07e9e91b8734..dfcbe235373e11fa563b56b8c4dca859556a0121 100644 (file)
@@ -352,9 +352,8 @@ class Command:
     # -- External world manipulation -----------------------------------
 
     def warn (self, msg):
-        sys.stderr.write("warning: %s: %s\n" %
-                         (self.get_command_name(), msg))
-
+        log.warn("warning: %s: %s\n" %
+                (self.get_command_name(), msg))
 
     def execute (self, func, args, msg=None, level=1):
         util.execute(func, args, msg, dry_run=self.dry_run)
index fcaa545a79992f22ec3b2f5354aeb5b8f4e77e44..6f949d517936c6c6ea4fd1ac6cc587be3d6f9fdd 100644 (file)
@@ -18,13 +18,14 @@ class Log:
 
     def _log(self, level, msg, args):
         if level >= self.threshold:
-            if not args:
-                # msg may contain a '%'. If args is empty,
-                # don't even try to string-format
-                print msg
+            if args:
+                msg = msg % args
+            if level in (WARN, ERROR, FATAL):
+                stream = sys.stderr
             else:
-                print msg % args
-            sys.stdout.flush()
+                stream = sys.stdout
+            stream.write('%s\n' % msg)
+            stream.flush()
 
     def log(self, level, msg, *args):
         self._log(level, msg, args)