public function offsetGet($offset)
    {
        if (!is_string($offset)) {
            throw new \Plop\Exception('Invalid identifier');
        }

        $parts = explode(':', $offset, 3);
        if (count($parts) != 3) {
            throw new \Plop\Exception('Invalid identifier');
        }
        list($method, $class, $ns) = $parts;

        $len = -strlen('\\');
        while (substr($ns, $len) == '\\') {
            $ns = (string) substr($ns, 0, $len);
        }

        // Namespace, class and method/function match.
        if (isset($this->loggers["$method:$class:$ns"])) {
            return $this->loggers["$method:$class:$ns"];
        }

        // Namespace and class match.
        if ($class != "" && isset($this->loggers[":$class:$ns"])) {
            return $this->loggers[":$class:$ns"];
        }

        // Namespace match.
        $parts = explode('\\', $ns);
        while (count($parts)) {
            $offset = implode('\\', $parts);
            if ($offset == '') {
                break;
            }

            if (isset($this->loggers["::$offset"])) {
                return $this->loggers["::$offset"];
            }
            array_pop($parts);
        }

        // Root logger.
        return $this->loggers['::'];
    }