pypa/pip — pull request #2008 by dstufft (2014-08-31 06:43:20+00:00)
Title: [WIP] Switch from using a homegrown logging solution to the stdlib logging module

#### Overview

This PR switches us away from using our own custom logging framework and instead uses a combination of the stdlib logging and the warnings module. This will ideally give us a few benefits:

* Make it easier for debug logging to include information from other libraries that we're using.
* Ideally have less issues with unicode handling as we're offloading that to the standard library.
* Use a system that more Python developers will be familiar with to make it easier for end users to contribute to pip.
* Make pip friendlier in an eventual future where we might support using pip as a library instead of only as a CLI application.
* Easily add nice features to the logging, such as being able to add an appending log instead of an overwriting log that is on by default which automatically limits it's size.

#### Details

* Logger - When logging things in pip you'll now use a ``logger`` module that comes from ``logging.getLogger(__name__)`` instead of a global one at ``pip.log:logger``.
* Logging Levels - We'll now have the standard logging levels, ``DEBUG``, ``INFO``, ``WARNING``, ``ERROR``, ``CRITICAL``. By default we'll log ``INFO`` and higher, while any ``--quiet`` configuration will change that to ``ERROR`` and higher, and any ``--verbose`` will change that to ``DEBUG`` and higher. The difference between ``ERROR`` and ``CRITICAL`` is that ``CRITICAL`` should generally only be used for *fatal* errors.
* Deprecations - Instead of using ``logger.deprecated()`` deprecations will now be handled by using ``warnings.warn()`` with special warnings from the ``pip.utils.deprecation`` module.
* Backports ``logging.config.dictConfig`` from Python 2.7 for use in Python 2.6.

#### Tasks

* [x] Switch from using pip.log:Logger to the stdlib logging module.
* [x] Switch to using the warnings module to handle deprecations.
* [x] Switch to using a logging formatter to handle indenting the log messages.
* [x] Create a context manager to indent all the logging messages inside of the context manager.
* [x] Simplify the ``--verbose`` and ``--quiet`` flags.
* [ ] Switch to using the stdlib logging modules to handle the log files that we write.
* [ ] Switch to using a custom log handler to colorize the output of the various levels.
* [ ] Use a UI module external to the logging system to handle progress indicators.
* [ ] Write tests for all of the new stuff and fix any broken tests.
* [ ] Refactor & Cleanup.