diff options
author | 2010-07-06 18:07:41 -0700 | |
---|---|---|
committer | 2010-07-06 18:07:41 -0700 | |
commit | aab6675b43d3bada568d8510621441004d8e09b6 (patch) | |
tree | acf0e55adf09fa1520e29f61ce939746fc2ceabd | |
parent | change to use the config['output'] variable (diff) | |
download | overlord-aab6675b43d3bada568d8510621441004d8e09b6.tar.gz overlord-aab6675b43d3bada568d8510621441004d8e09b6.tar.bz2 overlord-aab6675b43d3bada568d8510621441004d8e09b6.zip |
Add an output parameter to Message class and change the prints that weren't already re-directed to re-direct to it
-rw-r--r-- | layman/debug.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/layman/debug.py b/layman/debug.py index 41d084c..e5a5d61 100644 --- a/layman/debug.py +++ b/layman/debug.py @@ -44,6 +44,7 @@ class Message: # next time. def __init__(self, module = '', + out = sys.stdout, err = sys.stderr, dbg = sys.stderr, debugging_level = 4, @@ -54,6 +55,7 @@ class Message: mth = None, obj = None, var = None): + if mth == None: mth = ['*'] if obj == None: obj = ['*'] if var == None: var = ['*'] @@ -67,6 +69,9 @@ class Message: # Where should the error output go? This can also be a file self.error_out = err + # Where should the normal output go? This can also be a file + self.std_out = out + # The higher the level the more information you will get self.warn_lev = warn_level @@ -298,7 +303,7 @@ class Message: ## Output Functions def notice (self, note): - print note + print >> self.std_out, note def info (self, info, level = 4): @@ -309,7 +314,7 @@ class Message: return for i in info.split('\n'): - print self.maybe_color('green', '* ') + i + print >> self.std_out, self.maybe_color('green', '* ') + i def status (self, message, status, info = 'ignored'): @@ -322,7 +327,7 @@ class Message: return for i in lines[0:-1]: - print self.maybe_color('green', '* ') + i + print >> self.std_out, self.maybe_color('green', '* ') + i i = lines[-1] @@ -336,7 +341,7 @@ class Message: else: result = '[' + self.maybe_color('yellow', info) + ']' - print self.maybe_color('green', '* ') + i + ' ' + '.' * (58 - len(i)) \ + print >> self.std_out, self.maybe_color('green', '* ') + i + ' ' + '.' * (58 - len(i)) \ + ' ' + result def warn (self, warn, level = 4): @@ -348,7 +353,7 @@ class Message: return for i in warn.split('\n'): - print self.maybe_color('yellow', '* ') + i + print >> self.std_out, self.maybe_color('yellow', '* ') + i def error (self, error): |