summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-29 14:42:06 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-29 14:42:06 -0700
commitcc23412d7a4841667179d70571689bb41a167d32 (patch)
treeb3c6525eaae9cea75f083d7d477746d619c57f04 /bin
parent196c5e770ed1613803646a0177e144a3a4c2813e (diff)
downloadvyos-cloud-init-cc23412d7a4841667179d70571689bb41a167d32.tar.gz
vyos-cloud-init-cc23412d7a4841667179d70571689bb41a167d32.zip
If logging hasn't been enabled via '--debug' at least log the exceptions that occur to stderr.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/cloud-init19
1 files changed, 19 insertions, 0 deletions
diff --git a/bin/cloud-init b/bin/cloud-init
index 0330cb2b..22901e15 100755
--- a/bin/cloud-init
+++ b/bin/cloud-init
@@ -24,6 +24,7 @@
import argparse
import os
import sys
+import traceback
# This is more just for running from the bin folder so that
# cloud-init binary can find the cloudinit module
@@ -64,6 +65,18 @@ FREQ_SHORT_NAMES = {
LOG = logging.getLogger()
+# Used for when a logger may not be active
+# and we still want to print exceptions...
+def print_exc(msg=''):
+ if msg:
+ sys.stderr.write("%s\n" % (msg))
+ sys.stderr.write('-' * 60)
+ sys.stderr.write("\n")
+ traceback.print_exc(file=sys.stderr)
+ sys.stderr.write('-' * 60)
+ sys.stderr.write("\n")
+
+
def welcome(action):
msg = ("Cloud-init v. {{version}} running '{{action}}' at "
"{{timestamp}}. Up {{uptime}} seconds.")
@@ -151,6 +164,7 @@ def main_init(name, args):
(outfmt, errfmt) = util.fixup_output(init.cfg, name)
except:
util.logexc(LOG, "Failed to setup output redirection!")
+ print_exc("Failed to setup output redirection!")
if args.debug:
# Reset so that all the debug handlers are closed out
LOG.debug(("Logging being reset, this logger may no"
@@ -277,6 +291,9 @@ def main_modules(action_name, args):
util.logexc(LOG, ('Can not apply stage %s, '
'no datasource found!'
" Likely bad things to come!"), name)
+ print_exc(('Can not apply stage %s, '
+ 'no datasource found!'
+ " Likely bad things to come!") % (name))
if not args.force:
return 1
# Stage 3
@@ -326,6 +343,8 @@ def main_single(name, args):
# the module being ran (so continue on)
util.logexc(LOG, ("Failed to fetch your datasource,"
" likely bad things to come!"))
+ print_exc(("Failed to fetch your datasource,"
+ " likely bad things to come!"))
if not args.force:
return 1
# Stage 3