Setup logging on salt's runner CLI access. Fixes #5706.

Default log level is `warning`, though, since the master configuration file is shared, whatever the `log_level` defined on the master configuration file that's the value that will be used. To tweak the `salt-run` log level on the configuration file, independently from the master, you can use `cli_salt_run_log_level`(See #5609).
This commit is contained in:
Pedro Algarvio 2013-06-26 10:48:42 +01:00
parent ec2d260ab0
commit 86bd478370
2 changed files with 35 additions and 11 deletions

View File

@ -273,13 +273,35 @@ class SaltRun(parsers.SaltRunOptionParser):
'''
self.parse_args()
if self.config['verify_env']:
verify_env([
self.config['pki_dir'],
self.config['cachedir'],
],
self.config['user'],
permissive=self.config['permissive_pki_access'],
pki_dir=self.config['pki_dir'],
)
if (not self.config['log_file'].startswith('tcp://') or
not self.config['log_file'].startswith('udp://') or
not self.config['log_file'].startswith('file://')):
# Logfile is not using Syslog, verify
verify_files(
[self.config['log_file']],
self.config['user']
)
# Setup file logging!
self.setup_logfile_logger()
runner = salt.runner.Runner(self.config)
if self.options.doc:
runner._print_docs()
else:
# Run this here so SystemExit isn't raised anywhere else when
# someone tries to use the runners via the python API
try:
runner.run()
except SaltClientError as exc:
raise SystemExit(str(exc))
self.exit(0)
# Run this here so SystemExit isn't raised anywhere else when
# someone tries to use the runners via the python API
try:
runner.run()
except SaltClientError as exc:
raise SystemExit(str(exc))

View File

@ -805,9 +805,9 @@ class OutputOptionsMixIn(object):
)
group.add_option(
'--force-color', '--force-colour',
default=False,
action='store_true',
help='Force colored output'
default=False,
action='store_true',
help='Force colored output'
)
for option in self.output_options_group.option_list:
@ -1446,7 +1446,7 @@ class SaltCallOptionParser(OptionParser, ConfigDirMixIn, MergeConfigMixIn,
class SaltRunOptionParser(OptionParser, ConfigDirMixIn, MergeConfigMixIn,
TimeoutMixIn):
TimeoutMixIn, LogLevelMixIn):
__metaclass__ = OptionParserMeta
default_timeout = 1
@ -1455,7 +1455,9 @@ class SaltRunOptionParser(OptionParser, ConfigDirMixIn, MergeConfigMixIn,
# ConfigDirMixIn config filename attribute
_config_filename_ = 'master'
# LogLevelMixIn attributes
_default_logging_level_ = 'warning'
_default_logging_logfile_ = '/var/log/salt/master'
def _mixin_setup(self):