Kaydet (Commit) c7cd138b authored tarafından Tarek Ziadé's avatar Tarek Ziadé

using log.warn for sys.stderr

üst ef660e8e
...@@ -352,9 +352,8 @@ class Command: ...@@ -352,9 +352,8 @@ class Command:
# -- External world manipulation ----------------------------------- # -- External world manipulation -----------------------------------
def warn (self, msg): def warn (self, msg):
sys.stderr.write("warning: %s: %s\n" % log.warn("warning: %s: %s\n" %
(self.get_command_name(), msg)) (self.get_command_name(), msg))
def execute (self, func, args, msg=None, level=1): def execute (self, func, args, msg=None, level=1):
util.execute(func, args, msg, dry_run=self.dry_run) util.execute(func, args, msg, dry_run=self.dry_run)
......
...@@ -18,13 +18,14 @@ class Log: ...@@ -18,13 +18,14 @@ class Log:
def _log(self, level, msg, args): def _log(self, level, msg, args):
if level >= self.threshold: if level >= self.threshold:
if not args: if args:
# msg may contain a '%'. If args is empty, msg = msg % args
# don't even try to string-format if level in (WARN, ERROR, FATAL):
print msg stream = sys.stderr
else: else:
print msg % args stream = sys.stdout
sys.stdout.flush() stream.write('%s\n' % msg)
stream.flush()
def log(self, level, msg, *args): def log(self, level, msg, *args):
self._log(level, msg, args) self._log(level, msg, args)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment