"""
Logger
------

This module contains pywincffi's logger and provides functions to
configure the logger at runtime.
"""

import logging

try:
    NullHandler = logging.NullHandler

except AttributeError:  # pragma: no cover
    # Python 2.6 does not have a NullHandler
    class NullHandler(logging.Handler):
        def handle(self, record):
            pass

        def emit(self, record):
            pass

        def createLock(self):
            self.lock = None


logger = logging.getLogger("pywincffi")
logger.addHandler(NullHandler())


def configure(level, handler=None, formatter=None):
    """
    Enables pywincffi's logger, add formatting, handling and set
    the logging level.  Normally pywincffi's logger is not configured
    except for an
    """
    if formatter is None:
        formatter = logging.Formatter(
            "%(asctime)s %(name)s %(levelname)9s %(message)s",
            datefmt="%D %H:%M:%S"
        )

    if handler is None:
        handler = logging.StreamHandler()

    handler.setFormatter(formatter)
    logger.addHandler(handler)
    logger.setLevel(level)

"""
Logger
------

This module contains pywincffi's logger and provides functions to
configure the logger at runtime.
"""

import logging

try:
    NullHandler = logging.NullHandler

except AttributeError:  # pragma: no cover
    # Python 2.6 does not have a NullHandler
    class NullHandler(logging.Handler):
        def handle(self, record):
            pass

        def emit(self, record):
            pass

        def createLock(self):
            self.lock = None


logger = logging.getLogger("pywincffi")
logger.addHandler(NullHandler())


def configure(level, handler=None, formatter=None):
    """
    Enables pywincffi's logger, adds formatting, handling and sets
    the logging level.  Normally pywincffi's logger is not configured
    and logs nothing, this function will enable it however and can
    be useful for debugging.
    """
    if formatter is None:
        formatter = logging.Formatter(
            "%(asctime)s %(name)s %(levelname)9s %(message)s",
            datefmt="%D %H:%M:%S"
        )

    if handler is None:
        handler = logging.StreamHandler()

    handler.setFormatter(formatter)
    logger.addHandler(handler)
    logger.setLevel(level)

fix doc string