#! /usr/bin/env python2

import sys
import logging
import argparse

class FakeFile(object):
  def write(self, msgs):
    for msg in msgs.splitlines():
      log.info(msg)

def see(expr):
  # global log
  value = eval(expr)
  log.info('{expr}: {value}'.format(**locals()))

logging.basicConfig(format='%(asctime)s %(levelname)s %(pathname)s:%(lineno)d %(msg)s')
log = logging.getLogger()
log.setLevel(logging.DEBUG)

parser = argparse.ArgumentParser()
parser.add_argument('-v', '--verbose', dest='verbose', action='store_true')
parser.add_argument('files', metavar='file', nargs='*')

try:
  args = parser.parse_args()
except Exception as e:
  log.critical('Caught `{e!s}` from ArgumentParser.parse_args()'.format(**locals()))
  parser.print_help(sys.stderr)
  exit(1)

see('args.verbose')
see('args.files')

parser.print_help(FakeFile())
