From b80b2feeab301adf610ac32b7a33779e51e41383 Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Fri, 27 Sep 2013 20:39:54 -0400 Subject: [PATCH] add logging to script --- bin/employ | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bin/employ b/bin/employ index 92aa888..a3b616c 100755 --- a/bin/employ +++ b/bin/employ @@ -6,12 +6,15 @@ Usage: employ --help employ --version employ help (commands | command | managers | manager ) - employ run [ ...] + employ [--verbose] run [ ...] Global Options: -h, --help Show this message --version Show the version number +Run Options: + -v, --verbose Set log level of INFO + Help Commands: commands List all available commands command Print the docstring for the provided command @@ -20,11 +23,14 @@ Help Commands: """ from ConfigParser import RawConfigParser +import logging import sys from docopt import docopt import employ +from employ.logger import logger + def command_doc(command): all_commands = employ.available_commands() @@ -40,6 +46,7 @@ def list_commands(command=None): for cls in all_commands: print " %s" % cls + def manager_doc(manager): all_managers = employ.available_managers() if all_managers.get(manager): @@ -87,6 +94,14 @@ def run(manager_cls, config_file, setup_scripts): arguments = docopt(__doc__, help=True, version="employ %s" % employ.__version__) + +level = "INFO" if arguments["--verbose"] else "ERROR" +logging.basicConfig( + format='%(asctime)s - %(name) - %(message)s', + level=level, + stream=sys.stdout, + ) + if arguments["help"]: if arguments["commands"]: list_commands()