summaryrefslogtreecommitdiffstats
path: root/src/sbin
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-08-15 11:20:18 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-08-15 11:20:18 -0400
commitf2f5e9c8a8be6970c2683045ef9993ba60a0d63b (patch)
treecc4a3df003710ed839f35f24b2810fbbdfd03eff /src/sbin
parentd1073cc867ffc96952de4dddc5fb30d51fd5bf4e (diff)
downloadbcfg2-f2f5e9c8a8be6970c2683045ef9993ba60a0d63b.tar.gz
bcfg2-f2f5e9c8a8be6970c2683045ef9993ba60a0d63b.tar.bz2
bcfg2-f2f5e9c8a8be6970c2683045ef9993ba60a0d63b.zip
made logging to syslog configurable and default for all logging
Diffstat (limited to 'src/sbin')
-rwxr-xr-xsrc/sbin/bcfg216
-rwxr-xr-xsrc/sbin/bcfg2-admin3
-rwxr-xr-xsrc/sbin/bcfg2-info2
-rwxr-xr-xsrc/sbin/bcfg2-lint2
-rwxr-xr-xsrc/sbin/bcfg2-test2
5 files changed, 16 insertions, 9 deletions
diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2
index 4c1514117..21de6a3fd 100755
--- a/src/sbin/bcfg2
+++ b/src/sbin/bcfg2
@@ -51,7 +51,7 @@ class Client:
if self.setup['debug']:
level = 0
Bcfg2.Logger.setup_logging('bcfg2',
- to_syslog=False,
+ to_syslog=self.setup['syslog'],
level=level,
to_file=self.setup['logging'])
self.logger = logging.getLogger('bcfg2')
@@ -97,11 +97,13 @@ class Client:
script.write(probe.text)
script.close()
os.close(scripthandle)
- os.chmod(script.name, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH |
- stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH |
- stat.S_IWUSR) # 0755
+ os.chmod(script.name,
+ stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH |
+ stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH |
+ stat.S_IWUSR) # 0755
ret.text = os.popen(script.name).read().strip()
- self.logger.info("Probe %s has result:\n%s" % (name, ret.text))
+ self.logger.info("Probe %s has result:" % name)
+ self.logger.info(ret.text)
finally:
os.unlink(script.name)
except:
@@ -121,6 +123,8 @@ class Client:
# begin configuration
times['start'] = time.time()
+ self.logger.info("Starting Bcfg2 client run at %s" % times['start'])
+
if self.setup['file']:
# read config from file
try:
@@ -314,6 +318,8 @@ class Client:
"%s" % err)
raise SystemExit(2)
+ self.logger.info("Finished Bcfg2 client run at %s" % time.time())
+
if __name__ == '__main__':
signal.signal(signal.SIGINT, cb_sigint_handler)
client = Client()
diff --git a/src/sbin/bcfg2-admin b/src/sbin/bcfg2-admin
index 9b28d9bd5..8790cadee 100755
--- a/src/sbin/bcfg2-admin
+++ b/src/sbin/bcfg2-admin
@@ -50,7 +50,8 @@ def main():
level = logging.INFO
else:
level = logging.WARNING
- Bcfg2.Logger.setup_logging('bcfg2-admin', to_syslog=False, level=level)
+ Bcfg2.Logger.setup_logging('bcfg2-admin', to_syslog=setup['syslog'],
+ level=level)
# Provide help if requested or no args were specified
if (not setup['args'] or len(setup['args']) < 1 or
diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info
index bba8eca7c..d8dd4a3c8 100755
--- a/src/sbin/bcfg2-info
+++ b/src/sbin/bcfg2-info
@@ -664,7 +664,6 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.BaseCore):
self.do_loop()
if __name__ == '__main__':
- Bcfg2.Logger.setup_logging('bcfg2-info', to_syslog=False)
optinfo = dict(profile=Bcfg2.Options.CORE_PROFILE,
mconnect=Bcfg2.Options.SERVER_MCONNECT,
interactive=Bcfg2.Options.INTERACTIVE,
@@ -678,6 +677,7 @@ if __name__ == '__main__':
USAGE])
setup.parse(sys.argv[1:])
+ Bcfg2.Logger.setup_logging('bcfg2-info', to_syslog=setup['syslog'])
if setup['args'] and setup['args'][0] == 'help':
print(setup.hm)
sys.exit(0)
diff --git a/src/sbin/bcfg2-lint b/src/sbin/bcfg2-lint
index 8a5f55ae4..1038beca8 100755
--- a/src/sbin/bcfg2-lint
+++ b/src/sbin/bcfg2-lint
@@ -86,7 +86,7 @@ if __name__ == '__main__':
setup = Bcfg2.Options.OptionParser(optinfo)
setup.parse(sys.argv[1:])
- log_args = dict(to_syslog=False, to_console=logging.WARNING)
+ log_args = dict(to_syslog=setup['syslog'], to_console=logging.WARNING)
if setup['verbose']:
log_args['to_console'] = logging.DEBUG
Bcfg2.Logger.setup_logging('bcfg2-info', **log_args)
diff --git a/src/sbin/bcfg2-test b/src/sbin/bcfg2-test
index 83d409944..8323eeb22 100755
--- a/src/sbin/bcfg2-test
+++ b/src/sbin/bcfg2-test
@@ -73,7 +73,7 @@ def main():
setup.parse(sys.argv[1:])
if setup['verbose']:
- Bcfg2.Logger.setup_logging("bcfg2-test", to_syslog=False)
+ Bcfg2.Logger.setup_logging("bcfg2-test", to_syslog=setup['syslog'])
core = Bcfg2.Server.Core.BaseCore(setup)