diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2006-02-21 22:52:51 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2006-02-21 22:52:51 +0000 |
commit | 056a24205300a8d7c410b7537c6c31bbf979d8d1 (patch) | |
tree | 631a2e2a845206eb63f09d5606ec0ed0a6cffefb /src | |
parent | ed7df56e513ad4b3173de0ead803a4654510aff9 (diff) | |
download | bcfg2-056a24205300a8d7c410b7537c6c31bbf979d8d1.tar.gz bcfg2-056a24205300a8d7c410b7537c6c31bbf979d8d1.tar.bz2 bcfg2-056a24205300a8d7c410b7537c6c31bbf979d8d1.zip |
Fix output logging
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1761 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Client/Toolset.py | 2 | ||||
-rw-r--r-- | src/lib/Logging.py | 9 | ||||
-rwxr-xr-x | src/sbin/bcfg2 | 15 |
3 files changed, 12 insertions, 14 deletions
diff --git a/src/lib/Client/Toolset.py b/src/lib/Client/Toolset.py index dad808981..aedccce35 100644 --- a/src/lib/Client/Toolset.py +++ b/src/lib/Client/Toolset.py @@ -65,7 +65,7 @@ class Toolset(object): def CondDisplayState(self, phase): '''Conditionally print tracing information''' - self.logger.info('Phase: %s' % phase) + self.logger.info('\nPhase: %s' % phase) self.logger.info('Correct entries:\t%d' % self.states.values().count(True)) self.logger.info('Incorrect entries:\t%d' % self.states.values().count(False)) self.logger.info('Total managed entries:\t%d' % len(self.states.values())) diff --git a/src/lib/Logging.py b/src/lib/Logging.py index 70270ff23..afaed1c96 100644 --- a/src/lib/Logging.py +++ b/src/lib/Logging.py @@ -46,7 +46,7 @@ class TermiosFormatter(logging.Formatter): self.width = 80 else: # output to a pipe - self.width = sys.maxint + self.width = 32768 def format(self, record): '''format a record for display''' @@ -59,22 +59,21 @@ class TermiosFormatter(logging.Formatter): else: inner_lines = int(math.floor(float(len(line)) / line_len))+1 for i in xrange(inner_lines): - returns.append("%s: %s" % (record.name, line[i*line_len:(i+1)*line_len])) + returns.append("%s" % (line[i*line_len:(i+1)*line_len])) elif type(record.msg) == types.ListType: record.msg.sort() - msgwidth = self.width - len(record.name) - 2 + msgwidth = self.width columnWidth = max([len(item) for item in record.msg]) columns = int(math.floor(float(msgwidth) / (columnWidth+2))) lines = int(math.ceil(float(len(record.msg)) / columns)) for lineNumber in xrange(lines): indices = [idx for idx in [(colNum * lines) + lineNumber for colNum in range(columns)] if idx < len(record.msg)] - format = record.name + ':' + (len(indices) * (" %%-%ds " % columnWidth)) + format = (len(indices) * (" %%-%ds " % columnWidth)) returns.append(format % tuple([record.msg[idx] for idx in indices])) elif type(record.msg) == lxml.etree._Element: returns.append(str(xml_print(record.msg))) else: - returns.append("Got unsupported type %s" % (str(type(record.msg)))) returns.append(record.name + ':' + str(record.msg)) if record.exc_info: returns.append(self.formatException(record.exc_info)) diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2 index ec2f2fdbc..002dd6058 100755 --- a/src/sbin/bcfg2 +++ b/src/sbin/bcfg2 @@ -16,6 +16,13 @@ def cb_sigint_handler(signum, frame): class Client: ''' The main bcfg2 client class ''' def __init__(self, args): + level = 30 + if '-v' in sys.argv: + level = 20 + if '-d' in sys.argv: + level = 0 + Bcfg2.Logging.setup_logging('bcfg2', to_syslog=False, level=level) + self.logger = logging.getLogger('bcfg2') self.toolset = None self.config = None self.options = { @@ -89,16 +96,8 @@ class Client: 'password': '<password> ', 'retries': '<number of retries>' } - self.setup = {} self.get_setup(args) - level = 30 - if self.setup['verbose']: - level = 20 - if self.setup['debug']: - level = 0 - Bcfg2.Logging.setup_logging('bcfg2', to_syslog=False, level=level) - self.logger = logging.getLogger('bcfg2') self.logger.debug(self.setup) def load_toolset(self, toolset_name): |