Add warning() and substitution support to logger

This commit is contained in:
Stefano Rivera 2010-12-22 21:04:53 +02:00
parent 2c2aaf90b3
commit b94d134650

View File

@ -33,22 +33,27 @@ class Logger(object):
print "%s: I: %s" % (cls.script_name, " ".join(cmd)) print "%s: I: %s" % (cls.script_name, " ".join(cmd))
@classmethod @classmethod
def debug(cls, message): def debug(cls, message, *args):
if cls.verbose: if cls.verbose:
print "%s: D: %s" % (cls.script_name, message) print "%s: D: %s" % (cls.script_name, message % args)
@classmethod @classmethod
def error(cls, message): def error(cls, message, *args):
print >> sys.stderr, "%s: Error: %s" % (cls.script_name, message) print >> sys.stderr, "%s: Error: %s" % (cls.script_name, message % args)
@classmethod @classmethod
def info(cls, message): def warn(cls, message, *args):
print >> sys.stderr, "%s: Warning: %s" % (cls.script_name,
message % args)
@classmethod
def info(cls, message, *args):
if cls.verbose: if cls.verbose:
print "%s: I: %s" % (cls.script_name, message) print "%s: I: %s" % (cls.script_name, message % args)
@classmethod @classmethod
def normal(cls, message): def normal(cls, message, *args):
print "%s: %s" % (cls.script_name, message) print "%s: %s" % (cls.script_name, message % args)
@classmethod @classmethod
def set_verbosity(cls, verbose): def set_verbosity(cls, verbose):