From aa9189e89ec101fba8ca36919a7c800f8b28d5c0 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sun, 1 Jul 2012 00:19:49 -0700 Subject: Add a multi log function that can write to stderr, console and a log debug, useful in certain cases --- cloudinit/util.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'cloudinit/util.py') diff --git a/cloudinit/util.py b/cloudinit/util.py index 0c592656..e6219d66 100644 --- a/cloudinit/util.py +++ b/cloudinit/util.py @@ -271,6 +271,17 @@ def find_modules(root_dir): return entries +def multi_log(text, console=True, stderr=True, log=None): + if stderr: + sys.stderr.write(text) + if console: + with open('/dev/console', 'wb') as wfh: + wfh.write(text) + wfh.flush() + if log: + log.debug(text) + + def is_ipv4(instr): """ determine if input string is a ipv4 address. return boolean""" toks = instr.split('.') -- cgit v1.2.3