diff options
author | Raphaël Beamonte <raphael.beamonte@gmail.com> | 2013-01-05 14:05:13 -0500 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2013-01-10 20:44:13 +0100 |
commit | c97efc3aa95c0acc98a1cc76da7274e39ed1fe01 (patch) | |
tree | 277110cfc689974edab3bd902a07dfcbe651e9e4 | |
parent | cfa08819e134ca9d873331de9e84456e661410d3 (diff) | |
download | rteval-c97efc3aa95c0acc98a1cc76da7274e39ed1fe01.tar.gz |
Moves the update of the log verbosity to use it properly during modules instantiation
Previously, we used a default Log.INFO verbose level before parsing command line
arguments, as modules load is necessary to know all the available arguments. In this
patch, we added an small command line analysis for the verbose and debug arguments to
set properly the log verbosity before loading modules. Doing so, we are able to have
the wanted verbosity level before starting the load of modules, and not to have
unwanted messages during execution.
Signed-off-by: Raphaël Beamonte <raphael.beamonte@gmail.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
-rwxr-xr-x | rteval-cmd | 21 |
1 files changed, 13 insertions, 8 deletions
@@ -182,7 +182,7 @@ if __name__ == '__main__': try: # Prepare logging logger = Log() - logger.SetLogVerbosity(Log.INFO) + logger.SetLogVerbosity(Log.NONE) # setup initial configuration config = rtevalConfig.rtevalConfig(logger=logger) @@ -208,6 +208,18 @@ if __name__ == '__main__': config.AppendConfig('measurement', { 'cyclictest' : 'module'}) + # Prepare log levels before loading modules, not to have unwanted log messages + rtevcfg = config.GetSection('rteval') + if (sys.argv.count('-v')+sys.argv.count('--verbose')) > 0: + rtevcfg.verbose = True + if (sys.argv.count('-D')+sys.argv.count('--debug')) > 0: + rtevcfg.debugging = True + loglev = (not rtevcfg.quiet and (Log.ERR | Log.WARN)) \ + | (rtevcfg.verbose and Log.INFO) \ + | (rtevcfg.debugging and Log.DEBUG) + logger.SetLogVerbosity(loglev) + + # Load modules loadmods = LoadModules(config, logger=logger) measuremods = MeasurementModules(config, logger=logger) @@ -217,13 +229,6 @@ if __name__ == '__main__': measuremods.SetupModuleOptions(parser) cmd_args = parse_options(config, parser, sys.argv[1:]) - # Update log level, based on config/command line args - rtevcfg = config.GetSection('rteval') - loglev = (not rtevcfg.quiet and (Log.ERR | Log.WARN)) \ - | (rtevcfg.verbose and Log.INFO) \ - | (rtevcfg.debugging and Log.DEBUG) - logger.SetLogVerbosity(loglev) - logger.log(Log.DEBUG, "workdir: %s" % rtevcfg.workdir) # if --summarize was specified then just parse the XML, print it and exit |