Browse Source

add logging to script

master
Brett Langdon 12 years ago
parent
commit
b80b2feeab
1 changed files with 16 additions and 1 deletions
  1. +16
    -1
      bin/employ

+ 16
- 1
bin/employ View File

@ -6,12 +6,15 @@ Usage:
employ --help
employ --version
employ help (commands | command <command> | managers | manager <manager>)
employ <manager> run <config_file> [<setup_script> ...]
employ [--verbose] <manager> run <config_file> [<setup_script> ...]
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 <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()


Loading…
Cancel
Save