Commit 7009dddc authored by Marco Mariani's avatar Marco Mariani

fix log behavior for 'node format'; also support --log_file for all slapos commands

parent cc202553
...@@ -66,12 +66,12 @@ class SlapOSApp(cliff.app.App): ...@@ -66,12 +66,12 @@ class SlapOSApp(cliff.app.App):
kw['argparse_kwargs']['conflict_handler'] = 'resolve' kw['argparse_kwargs']['conflict_handler'] = 'resolve'
parser = super(SlapOSApp, self).build_option_parser(*args, **kw) parser = super(SlapOSApp, self).build_option_parser(*args, **kw)
# add an alias for --log-file # add two aliases for --log-file (for compatibility with old commands)
parser.add_argument( parser.add_argument(
'--log-file', '--logfile', '--log-file', '--logfile', '--log_file',
action='store', action='store',
default=None, default=None,
help='Specify a file to log output. Disabled by default.', help='Specify a file to log output. Only console by default.',
) )
# always show tracebacks on errors # always show tracebacks on errors
......
...@@ -6,8 +6,6 @@ import sys ...@@ -6,8 +6,6 @@ import sys
from slapos.cli.config import ConfigCommand from slapos.cli.config import ConfigCommand
from slapos.format import do_format, FormatConfig, tracing_monkeypatch, UsageError from slapos.format import do_format, FormatConfig, tracing_monkeypatch, UsageError
# XXX TODO: handle log_file (old) vs log-file (new)
class FormatCommand(ConfigCommand): class FormatCommand(ConfigCommand):
""" """
...@@ -27,9 +25,6 @@ class FormatCommand(ConfigCommand): ...@@ -27,9 +25,6 @@ class FormatCommand(ConfigCommand):
help="Path to a JSON version of the computer's XML (for development only).", help="Path to a JSON version of the computer's XML (for development only).",
default=None) default=None)
ap.add_argument('-l', '--log_file',
help="The path to the log file used by the script.")
ap.add_argument('-i', '--input_definition_file', ap.add_argument('-i', '--input_definition_file',
help="Path to file to read definition of computer instead of " help="Path to file to read definition of computer instead of "
"declaration. Using definition file allows to disable " "declaration. Using definition file allows to disable "
...@@ -67,7 +62,7 @@ class FormatCommand(ConfigCommand): ...@@ -67,7 +62,7 @@ class FormatCommand(ConfigCommand):
conf.mergeConfig(args, configp) conf.mergeConfig(args, configp)
if not args.log_file and conf.log_file: if not self.app.options.log_file and conf.log_file:
# no log file is provided by argparser, # no log file is provided by argparser,
# we set up the one from config # we set up the one from config
file_handler = logging.FileHandler(conf.log_file) file_handler = logging.FileHandler(conf.log_file)
......
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