@public<EOL>def setup_logging(verbosity=<NUM_LIT:0>):
import pkgutil<EOL>import logging<EOL>import codekit<EOL>def iter_namespace(ns_pkg):<EOL><INDENT>return pkgutil.iter_modules(ns_pkg.__path__, ns_pkg.__name__ + "<STR_LIT:.>")<EOL><DEDENT>codekit_mods = [name for finder, name, ispkg in iter_namespace(codekit)<EOL>if ispkg is False]<EOL>codekit_mods = [m for m in codekit_mods<EOL>if m != __name__]<EOL>codekit_mods = [m for m in codekit_mods<EOL>if m in sys.modules]<EOL>logging_funcs = []<EOL>for m in codekit_mods:<EOL><INDENT>try:<EOL><INDENT>lsetup = getattr(sys.modules[m], '<STR_LIT>')<EOL>lsetup(verbosity=verbosity)<EOL>logging_funcs.append(lsetup)<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT>logging.basicConfig()<EOL>global logger<EOL>logger = logging.getLogger('<STR_LIT>')<EOL>if verbosity:<EOL><INDENT>logger.setLevel(logging.DEBUG)<EOL><DEDENT>else:<EOL><INDENT>logger.setLevel(logging.INFO)<EOL><DEDENT>[debug("<STR_LIT>".format(m=f.__module__, f=f.__name__))<EOL>for f in logging_funcs]<EOL>
Configure python `logging`.  This is required before the `debug()`,
    `info()`, etc. functions may be used.

    If any other `codekit.*` modules, which are not a "package", have been
    imported, and they have a `setup_logging()` function, that is called before
    `logging` is configured.  This gives other modules a chance to configure
    their own logging.

    As an example, if `progressbar2` is being used, it needs to be configure a
    `sys.stderr` wrapper before `logging` is configured.  Thus, some gymnastics
    are being done to delay `logging` setup while simultanously not requiring
    that `progressbar2` be imported unless it is actually being used.

    Parameters
    ----------
    verbosity: int
        Logging / output verbosity level. 1 is useful for more purposes while
        2+ is generaly TMI.