'Determine an appropriate log level for the given namespace.
This respects dots in namespaces; for example, if you have previously
invoked C{setLogLevelForNamespace("mypackage", LogLevel.debug)}, then
C{logLevelForNamespace("mypackage.subpackage")} will return
C{LogLevel.debug}.
@param namespace: A logging namespace, or L{None} for the default
namespace.
@type namespace: L{str} (native string)
@return: The log level for the specified namespace.
@rtype: L{LogLevel}'

def logLevelForNamespace(self, namespace):

    if (not namespace):
        return self._logLevelsByNamespace[None]
    if (namespace in self._logLevelsByNamespace):
        return self._logLevelsByNamespace[namespace]
    segments = namespace.split('.')
    index = (len(segments) - 1)
    while (index > 0):
        namespace = '.'.join(segments[:index])
        if (namespace in self._logLevelsByNamespace):
            return self._logLevelsByNamespace[namespace]
        index -= 1
    return self._logLevelsByNamespace[None]
