Did I find the right examples for you? yes no

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)
Initialize base logger named 'wsgidav'.

The base logger is filtered by the `verbose` configuration option.
Log entries will have a time stamp and thread id.

:Parameters:
    verbose : int
        Verbosity configuration (0..3) 
    enable_loggers : string list
        List of module logger names, that will be switched to DEBUG level.(more...)

        def initLogging(verbose=2, enable_loggers=[]):
    """Initialize base logger named 'wsgidav'.

    The base logger is filtered by the `verbose` configuration option.
    Log entries will have a time stamp and thread id.
    
    :Parameters:
        verbose : int
            Verbosity configuration (0..3) 
        enable_loggers : string list
            List of module logger names, that will be switched to DEBUG level.
         
    Module loggers
    ~~~~~~~~~~~~~~
    Module loggers (e.g 'wsgidav.lock_manager') are named loggers, that can be
    independently switched to DEBUG mode.
    
    Except for verbosity, they will inherit settings from the base logger.

    They will suppress DEBUG level messages, unless they are enabled by passing 
    their name to util.initLogging().

    If enabled, module loggers will print DEBUG messages, even if verbose == 2.   
    
    Example initialize and use a module logger, that will generate output, 
    if enabled (and verbose >= 2):
        
    .. python::
        _logger = util.getModuleLogger(__name__)
        [..]
        _logger.debug("foo: '%s'" % s)

    This logger would be enabled by passing its name to initLoggiong():
    
    .. python::
        enable_loggers = ["lock_manager",
                          "property_manager",
                         ]
        util.initLogging(2, enable_loggers)

    
    Log level matrix
    ~~~~~~~~~~~~~~~~
    =======  ======  ===========  ======================  =======================
    verbose  util                        Log level 
    -------  ------  ------------------------------------------------------------
      n      ()      base logger  module logger(enabled)  module logger(disabled)
    =======  ======  ===========  ======================  =======================
      0      write   ERROR        ERROR                   ERROR
      1      status  WARN         WARN                    WARN
      2      note    INFO         DEBUG                   INFO
      3      debug   DEBUG        DEBUG                   INFO
    =======  ======  ===========  ======================  =======================
    """

    formatter = logging.Formatter("<%(thread)d> [%(asctime)s.%(msecs)d] %(name)s:  %(message)s",
                                  "%H:%M:%S")
    
    # Define handlers
    consoleHandler = logging.StreamHandler(sys.stdout)
#    consoleHandler = logging.StreamHandler(sys.stderr)
    consoleHandler.setFormatter(formatter)
    consoleHandler.setLevel(logging.DEBUG)

    # Add the handlers to the base logger
    logger = logging.getLogger(BASE_LOGGER_NAME)

    if verbose >= 3: # --debug
        logger.setLevel(logging.DEBUG)
    elif verbose >= 2: # --verbose
        logger.setLevel(logging.INFO)
    elif verbose >= 1: # standard 
        logger.setLevel(logging.WARN)
        consoleHandler.setLevel(logging.WARN)
    else: # --quiet
        logger.setLevel(logging.ERROR)
        consoleHandler.setLevel(logging.ERROR)

    # Don't call the root's handlers after our custom handlers
    logger.propagate = False
    
    # Remove previous handlers
    for hdlr in logger.handlers[:]:  # Must iterate an array copy
        try:
            hdlr.flush()
            hdlr.close()
        except:
            pass
        logger.removeHandler(hdlr)

    logger.addHandler(consoleHandler)

    if verbose >= 2:
        for e in enable_loggers:
            if not e.startswith(BASE_LOGGER_NAME + "."):
                e = BASE_LOGGER_NAME + "." + e
            l = logging.getLogger(e.strip())
#            if verbose >= 2:
#                log("Logger(%s).setLevel(DEBUG)" % e.strip())
            l.setLevel(logging.DEBUG)        
        


src/w/s/WsgiDAV-1.1.0/wsgidav/wsgidav_app.py   WsgiDAV(Download)
    def __init__(self, config):
        self.config = config
 
        util.initLogging(config["verbose"], config.get("enable_loggers", []))
 

src/w/s/wsgidav-HEAD/wsgidav/wsgidav_app.py   wsgidav(Download)
    def __init__(self, config):
        self.config = config
 
        util.initLogging(config["verbose"], config.get("enable_loggers", []))