protected function log($level, $message, array $context = [])
    {
        if ($this->logger) {
            $metadata = $this->getMetadataBag();

            $context['metadata'] = [
                'created' => $metadata->getCreated(),
                'lifetime' => $metadata->getLifetime(),
                'lastused' => $metadata->getLastUsed(),
                'name' => $metadata->getName(),
            ];

            if ($this->isStarted()) {
                $attributes = $this->getBag('attributes');

                if ($attributes instanceof SessionBagProxy) {
                    $attributes = $attributes->getBag();
                }

                if ($attributes instanceof AttributeBagInterface) {
                    $context['metadata']['uID'] = $attributes->get('uID', null);
                    $context['metadata']['uGroups'] = array_values($attributes->get('uGroups', []));
                }
            }

            $this->logger->log($level, $message, $context);
        }
    }