Formats a {@link \n2n\log4php\logging\LoggingEvent} in conformance with the log4php.dtd.

@param \n2n\log4php\logging\LoggingEvent $event
@return string
322209
public function format(\n2n\log4php\logging\LoggingEvent $event) {
		$ns = $this->namespacePrefix;
		
		$loggerName = $event->getLoggerName();
		$timeStamp = number_format((float)($event->getTimeStamp() * 1000), 0, '', '');
		$thread = $event->getThreadName();
		$level = $event->getLevel()->toString();

		$buf  = "<$ns:event logger=\"{$loggerName}\" level=\"{$level}\" thread=\"{$thread}\" timestamp=\"{$timeStamp}\">".PHP_EOL;
		$buf .= "<$ns:message>"; 
		$buf .= $this->encodeCDATA($event->getRenderedMessage()); 
		$buf .= "</$ns:message>".PHP_EOL;

		$ndc = $event->getNDC();
		if(!empty($ndc)) {
			$buf .= "<$ns:NDC><![CDATA[";
			$buf .= $this->encodeCDATA($ndc);
			$buf .= "]]></$ns:NDC>".PHP_EOL;
		}
		
		$mdcMap = $event->getMDCMap();
		if (!empty($mdcMap)) {
			$buf .= "<$ns:properties>".PHP_EOL;
			foreach ($mdcMap as $name=>$value) {
				$buf .= "<$ns:data name=\"$name\" value=\"$value\" />".PHP_EOL;
			}
			$buf .= "</$ns:properties>".PHP_EOL;
		}

		if ($this->getLocationInfo()) {
			$locationInfo = $event->getLocationInformation();
			$buf .= "<$ns:locationInfo ". 
					"class=\"" . $locationInfo->getClassName() . "\" ".
					"file=\"" .  htmlentities($locationInfo->getFileName(), ENT_QUOTES) . "\" ".
					"line=\"" .  $locationInfo->getLineNumber() . "\" ".
					"method=\"" . $locationInfo->getMethodName() . "\" ";
			$buf .= "/>".PHP_EOL;
		}

		$buf .= "</$ns:event>".PHP_EOL;
		
		return $buf;
	}
13504
public function getEventPrefix() {
    static $prefix;
    if (!$prefix) {
      if (defined(static::class.'::EVENT_PREFIX'))
        $prefix = static::EVENT_PREFIX;
      else
        $prefix = strtolower(array_slice(explode('\\', static::class), -1)[0]);
    }
    return $prefix;
  }
209905
public function FormatContent($Log) {
      $Data = $Log['Data'];

      // TODO: Check for a custom log type handler.

      switch ($Log['RecordType']) {
         case 'Activity':
            $Result = $this->FormatKey('Story', $Data);
            break;
         case 'Discussion':
            $Result =
               '<b>'.$this->FormatKey('Name', $Data).'</b><br />'.
               $this->FormatKey('Body', $Data);
            break;
         case 'ActivityComment':
         case 'Comment':
            $Result = $this->FormatKey('Body', $Data);
            break;
         case 'Configuration':
            $Result = $this->FormatConfiguration($Data);
            break;
         case 'Registration':
         case 'User':
            $Result = $this->FormatRecord(array('Email', 'Name'), $Data);
            if ($DiscoveryText = GetValue('DiscoveryText', $Data)) {
               $Result .= '<br /><b>'.T('Why do you want to join?').'</b><br />'.Gdn_Format::Display($DiscoveryText);
            }
            if (GetValue('Banned', $Data)) {
               $Result .= "<br />".T('Banned');
            }
            break;
         default:
            $Result = '';
      }
      return $Result;
   }
114938
protected function getEventSubtype(EventInterface $event)
    {
        $subevent = '';
        if ($event instanceof CtcpEvent) {
            $subevent = 'ctcp.' . strtolower($event->getCtcpCommand());
        } elseif ($event instanceof UserEvent) {
            $subevent = strtolower($event->getCommand());
        } elseif ($event instanceof ServerEvent) {
            $subevent = strtolower($event->getCode());
        }
        return $subevent;
    }
947341
protected function _format($log)
    {
        $replaced = [];

        $replaced[':date'] = date('Y-m-d\TH:i:s', $log->timestamp) . sprintf('.%03d', ($log->timestamp - (int)$log->timestamp) * 1000);
        $replaced[':client_ip'] = $log->client_ip ?: '-';
        $replaced[':request_id'] = $log->request_id ?: '-';
        $replaced[':request_id16'] = $log->request_id ? substr($log->request_id, 0, 16) : '-';
        $replaced[':category'] = $log->category;
        $replaced[':location'] = "$log->file:$log->line";
        $replaced[':level'] = strtoupper($log->level);
        if ($log->category === 'exception') {
            $replaced[':message'] = '';
            /** @noinspection SuspiciousAssignmentsInspection */
            $replaced[':message'] = preg_replace('#[\\r\\n]+#', '\0' . strtr($this->_format, $replaced), $log->message) . PHP_EOL;
        } else {
            $replaced[':message'] = $log->message . PHP_EOL;
        }

        return strtr($this->_format, $replaced);
    }
406876
public function format($event)
    {
        $results = [];

        foreach ($event as $key => $value) {
            if ('extra' === $key && is_array($value)) {
                $results[$key] = $this->format($value);
            } else {
                $results[$key] = $this->normalize($value);
            }
        }

        return $results;
    }
525054
protected function getEventHandlers($event)
    {
        $logger = $this->getLogger();
        $handlers = array();

        foreach ($this->plugins as $plugin) {
            $callbacks = $plugin->getSubscribedEvents();
            if (!is_array($callbacks)) {
                $logger->warning('Plugin returns non-array value for event callbacks', array(
                    'plugin' => get_class($plugin),
                    'callbacks' => $callbacks,
                ));
                continue;
            }
            if (!isset($callbacks[$event])) {
                $logger->debug('Plugin does not handle event', array(
                    'plugin' => get_class($plugin),
                    'event' => $event,
                ));
                continue;
            }
            $callback = $callbacks[$event];
            $pluginCallback = array($plugin, $callback);
            if (is_callable($pluginCallback)) {
                $handlers[] = $pluginCallback;
            } elseif (is_callable($callback)) {
                $handlers[] = $callback;
            } else {
                $logger->warning('Plugin returns invalid event callback', array(
                    'plugin' => get_class($plugin),
                    'event' => $event,
                    'callback' => $callback,
                ));
            }
        }

        return $handlers;
    }
614918
public function getEventCallbacks($event = null)
    {
        if ($event === null) {
            return $this->eventCallbacks;
        }

        return $this->eventCallbacks[strtolower($event)] ?? [];
    }
276287
public static function format_event_for_fullcalendar($event)
    {
        $bgColor = '#999'; //default
        $textColor = '#FFF'; //default
        $borderColor = '#555';

        $arr = array(
            'id'        => $event->ID,
            'title'     => $event->Title,
            'start'     => self::format_datetime_for_fullcalendar($event->StartDateTime),
            'end'       => self::format_datetime_for_fullcalendar($event->EndDateTime),
            'allDay'        => $event->isAllDay(),
            'className' => $event->ClassName,
            //event calendar
            'backgroundColor' => $bgColor,
            'textColor' => '#FFFFFF',
            'borderColor' => $borderColor,
        );
        return $arr;
    }
1152556
private function normalizeEvent($event)
    {
        if (is_object($event)) {
            $event = get_class($event);
        }

        if (preg_match('/^bootstrapp(ing|ed): /', $event)) {
            return $event;
        }

        // Events can be formatted as 'event.name: parameters'
        $segments = explode(':', $event);

        return $segments[0];
    }
850156
protected function format(\n2n\log4php\logging\LoggingEvent $event) {
		$timestampSec = (int) $event->getTimestamp();
		$timestampUsec = (int) (($event->getTimestamp() - $timestampSec) * 1000000);

		$document = array(
			'timestamp' => new MongoDate($timestampSec, $timestampUsec),
			'level' => $event->getLevel()->toString(),
			'thread' => (int) $event->getThreadName(),
			'message' => $event->getMessage(),
			'loggerName' => $event->getLoggerName() 
		);	

		$locationInfo = $event->getLocationInformation();
		if ($locationInfo != null) {
			$document['fileName'] = $locationInfo->getFileName();
			$document['method'] = $locationInfo->getMethodName();
			$document['lineNumber'] = ($locationInfo->getLineNumber() == 'NA') ? 'NA' : (int) $locationInfo->getLineNumber();
			$document['className'] = $locationInfo->getClassName();
		}	

		$throwableInfo = $event->getThrowableInformation();
		if ($throwableInfo != null) {
			$document['exception'] = $this->formatThrowable($throwableInfo->getThrowable());
		}
		
		return $document;
	}
1126777
public function format(EventInterface $event) {
        $response = $event->getResponse();
        $model = $response->getModel();

        if ($response->getStatusCode() === 204 || !$model) {
            // No content to write
            return;
        }

        $request = $event->getRequest();

        // If we are dealing with an image we want to trigger an event that handles a possible
        // conversion
        if ($model instanceof Model\Image) {
            $outputConverterManager = $event->getOutputConverterManager();
            $eventManager = $event->getManager();

            if (
                ($model->getExtension() !== $this->formatter) &&
                ($outputConverterManager->getMimeTypeFromExtension($this->formatter) !== $model->getMimeType()) &&
                $outputConverterManager->supportsExtension($this->formatter)
            ) {
                $outputConverterManager->convert($model, $this->formatter);
            // for clarity - if we just have a requested compression / quality value, we still have to invoke the
            // conversion / writer for the existing format
            } else if (
                $model->getOutputQualityCompression() &&
                $outputConverterManager->supportsExtension($this->formatter)
            ) {
                $outputConverterManager->convert($model, $this->formatter);
            }

            // Finished transforming the image
            $eventManager->trigger('image.transformed', ['image' => $model]);

            $formattedData = $model->getBlob();
            $contentType = $model->getMimeType();
        } else {
            // Create an instance of the formatter
            $formatter = $this->formatters[$this->formatter];

            $formattedData = $formatter->format($model);
            $contentType = $formatter->getContentType();
        }

        if ($contentType === 'application/json') {
            foreach (['callback', 'jsonp', 'json'] as $validParam) {
                if ($request->query->has($validParam)) {
                    $formattedData = sprintf("%s(%s)", $request->query->get($validParam), $formattedData);
                    break;
                }
            }
        }

        $response->headers->add([
            'Content-Type' => $contentType,
            'Content-Length' => strlen($formattedData),
        ]);

        if ($request->getMethod() !== 'HEAD') {
            $response->setContent($formattedData);
        }
    }
1031765
public function onLog(LogGenericEvent $event)
    {
        $log = null;
        $logCreated = false;

        if (!($event instanceof LogNotRepeatableInterface) || !$this->isARepeat($event)) {
            $log = $this->createLog($event);
            $logCreated = true;
        }

        // Increment view count
        if ($event instanceof LogResourceReadEvent) {
            // Get connected user
            $tokenStorage = $this->container->get('security.token_storage');
            $token = $tokenStorage->getToken();
            $user = $token ? $token->getUser() : null;

            // Increment view count if viewer is not creator of the resource
            if (is_null($user) || is_string($user) || $user !== $event->getResource()->getCreator()) {
                // TODO : add me in an event on the resource 'open'
                $this->resourceManager->addView($event->getResource());
            }
            if ($logCreated && !empty($user) && 'anon.' !== $user && 'directory' !== $event->getResource()->getResourceType()->getName()) {
                $this->resourceEvalManager->updateResourceUserEvaluationData(
                    $event->getResource(),
                    $user,
                    new \DateTime(),
                    ['status' => AbstractResourceEvaluation::STATUS_OPENED],
                    ['status' => true],
                    false
                );
            }
        }
        if ($logCreated && $log && (
            $event instanceof LogUserLoginEvent ||
            $event instanceof LogWorkspaceEnterEvent ||
            $event instanceof LogResourceReadEvent ||
            $event instanceof LogWorkspaceToolReadEvent ||
            $event instanceof LogDesktopToolReadEvent ||
            $event instanceof LogAdminToolReadEvent
        )) {
            $this->logConnectManager->manageConnection($log);
        }
    }
1228410
private function getEventLevel(Event $event)
    {
        $type = $event->getType();

        switch ($type) {
            case Event::INFO:    return LogLevel::INFO;
            case Event::SUCCESS: return LogLevel::NOTICE;
            case Event::WARNING: return LogLevel::WARNING;
            case Event::ERROR:   return LogLevel::ERROR;
        }

        throw new \InvalidArgumentException("$type is not a valid event type");
    }
671686
protected function _write($event)
    {
        $priorityName = self::DEFAULT_PRIORITY_NAME;

        if (is_array($event) && isset($event['priorityName'])) {
            $priorityName = $event['priorityName'];
        }

        $line = $this->_formatter->format($event);

        $subPriority = null;

        isset($event['subPriority']) ? $subPriority = $event['subPriority'] : null;

        $stream = $this->_createCurrentStream($priorityName, $subPriority);

        if (false === @fwrite($stream, $line)) {
            throw new \Zend_Log_Exception("Unable to write to stream");
        }

        return $this;
    }
184230
protected static function getProjectDir(Event $event): string
    {
        return $event->getComposer()->getConfig()->get('vendor-dir')
            . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
    }
729264
public function col_component($event) {
        // Component.
        $componentname = $event->component;
        if (($event->component === 'core') || ($event->component === 'legacy')) {
            return  get_string('coresystem');
        } else if (get_string_manager()->string_exists('pluginname', $event->component)) {
            return get_string('pluginname', $event->component);
        } else {
            return $componentname;
        }
    }