Generate an error stack dump.
@param $event CErrorEvent
@return string
429784
public function logErrorEvent($event)
    {
        // create a new AuditError
        $auditError = new AuditError;
        $auditError->created = time();
        $auditError->status = 'new';
        $auditError->code = 500;
        $auditError->message = $event->message;
        $auditError->file = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $event->file);
        $auditError->line = $event->line;
        $auditError->source_code = AuditHelper::pack($this->renderSourceCode($auditError->file, $auditError->line, $this->maxSourceLines));

        // get the trace info and stack_dump
        $trace = debug_backtrace();
        // skip the first 3 stacks as they do not tell the error position
        if (count($trace) > 6)
            $trace = array_slice($trace, 6);
        $auditError->trace = '';
        foreach ($trace as $i => $t) {
            if (!isset($t['file']))
                $trace[$i]['file'] = 'unknown';
            $trace[$i]['file'] = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $trace[$i]['file']);

            if (!isset($t['line']))
                $trace[$i]['line'] = 0;

            if (!isset($t['function']))
                $trace[$i]['function'] = 'unknown';

            $auditError->trace .= "#$i {$trace[$i]['file']}({$trace[$i]['line']}): ";
            if (isset($t['object']) && is_object($t['object']))
                $auditError->trace .= get_class($t['object']) . '->';
            $auditError->trace .= "{$trace[$i]['function']}()\n";

            unset($trace[$i]['object']);

            if (isset($trace[$i]['args']))
                $trace[$i]['args'] = $this->cleanTrace($trace[$i]['args']);
        }
        $auditError->traces = json_encode($trace);
        $auditError->stack_trace = AuditHelper::pack($this->renderStackTrace($trace));

        // get the type info
        switch ($event->code) {
            case E_WARNING:
                $auditError->type = 'PHP warning';
                break;
            case E_NOTICE:
                $auditError->type = 'PHP notice';
                break;
            case E_USER_ERROR:
                $auditError->type = 'User error';
                break;
            case E_USER_WARNING:
                $auditError->type = 'User warning';
                break;
            case E_USER_NOTICE:
                $auditError->type = 'User notice';
                break;
            case E_RECOVERABLE_ERROR:
                $auditError->type = 'Recoverable error';
                break;
            default:
                $auditError->type = 'PHP error';
        }

        // get the AuditRequest
        $auditRequest = $this->getAuditRequest();
        $auditError->audit_request_id = $auditRequest ? $auditRequest->id : 0;

        // generate a hash of the error
        $auditError->hash = $this->hash($auditError->message . $auditError->file . $auditError->line);

        // save the AuditError
        $auditError->save(false);
    }
5839
public function onPostAutoloadDump(Event $event)
    {
        $this->io->writeError('<info>Generating extensions files</info>');
        foreach ($this->getPackages() as $package) {
            if ($package instanceof \Composer\Package\CompletePackageInterface) {
                $this->processPackage($package);
            }
        }
        $this->processPackage($this->composer->getPackage());

        foreach ($this->data as $name => $data) {
            $this->saveFile($this->buildOutputPath($name), $data);
        }
    }
1363062
public function getEvent(string $event)
    {
        $class = (string)$this->sprintf(':namespace\Event\:event', __NAMESPACE__, $event);

        if (class_exists($class)) {
            return new $class($this);
        }

        return null;
    }
1070608
public function handle($event)
	{
		// set event as handled to prevent it from being handled by other event handlers
		$event->handled=true;

		if($this->discardOutput)
		{
			$gzHandler=false;
			foreach(ob_list_handlers() as $h)
			{
				if(strpos($h,'gzhandler')!==false)
					$gzHandler=true;
			}
			// the following manual level counting is to deal with zlib.output_compression set to On
			// for an output buffer created by zlib.output_compression set to On ob_end_clean will fail
			for($level=ob_get_level();$level>0;--$level)
			{
				if(!@ob_end_clean())
					ob_clean();
			}
			// reset headers in case there was an ob_start("ob_gzhandler") before
			if($gzHandler && !headers_sent() && ob_list_handlers()===array())
			{
				if(function_exists('header_remove')) // php >= 5.3
				{
					header_remove('Vary');
					header_remove('Content-Encoding');
				}
				else
				{
					header('Vary:');
					header('Content-Encoding:');
				}
			}
		}

		if($event instanceof CExceptionEvent)
			$this->handleException($event->exception);
		else // CErrorEvent
			$this->handleError($event);
	}
752636
public function format($event)
    {
        $event = $this->reachUpFirstNestedLevel($event);
        $event = $this->clearEmptyArrayInEvent($event);
        return json_encode($event);
    }
175863
protected function getEventOutput(Event $event)
    {
        if (! $event->output ||
            $event->output === $event->getDefaultOutput() ||
            $event->shouldAppendOutput ||
            ! file_exists($event->output)) {
            return '';
        }

        return trim(file_get_contents($event->output));
    }
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");
    }
68175
protected function _write($event)
    {
        $data = array();
        if (empty($this->getColumnMap())) {
            $data = $event;
        } else {
            foreach ($this->getColumnMap() as $name => $value) {
                if (isset($event[$name])) {
                    $data[$name] = $event[$name];
                }
            }
        }

        $entry = new $this->modelClass();
        $entry->fromArray($data);
        $entry->save();

        return $this;
    }
93274
static function _handleErrors($error, $errstr = '', $errfile = '', $errline = 0)
    {
        $ErrorType = self::ERR_TYP_EXCEPTION;
        if (! $error instanceof \Exception) {
            if (interface_exists('Throwable', false) && $error instanceof \Throwable)
                VOID;
            else {
                $ErrorType = self::ERR_TYP_ERROR;

                ## handle errors
                $error = new ErrorException(
                    $errstr, $error, 1, $errfile, $errline
                );
            }
        }

        ## happen when start handleError() but within codeblock an exception rised
        ## so code follow will stop then we need cleanup to first exception stack
        while (self::getStackNum() && $Stack = &self::$_STACK[self::getStackNum()-1]) {
            if ($ErrorType === $Stack['error_type'])
                break;

            self::handleDone();
        }

        $Stack['has_handled_error'] = $error;

        // ...

        if (!isset($Stack['callable']) || $Stack['callable'] === null)
            return;

        $currLevel = self::getStackNum();
        try {
            ## call user error handler callable
            ## exception will passed as errno on exception catch
            call_user_func($Stack['callable'], $error);

        } catch (\Exception $e) {
            ## during handling an error if any exception happen it must handle with parent handler
            if (self::getStackNum() == $currLevel)
                ## close current handler if not, the handleDone may be called from within handler callable
                self::handleDone();

            if ($Stack['error_type'] == self::ERR_TYP_ERROR)
                ## Just throw exception, it might handled with exception handlers
                throw $e;

            $isHandled = false;
            while (self::hasHandling()) {
                $Stack = & self::$_STACK[self::getStackNum()-1];
                if ($Stack['error_type'] == self::ERR_TYP_EXCEPTION) {
                    $isHandled = true;
                    self::_handleErrors($e);
                    break;
                }

                self::handleDone();
            }

            if (!$isHandled)
                ## throw exception if it not handled
                throw $e;
        }
    }
614918
public function getEventCallbacks($event = null)
    {
        if ($event === null) {
            return $this->eventCallbacks;
        }

        return $this->eventCallbacks[strtolower($event)] ?? [];
    }
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;
    }
220548
private function getEventMessage(Event $event)
    {
        return json_encode([
            'title' => $event->getTitle(),
            'text' => $event->getText(),
            'timestamp' => $event->getTimeStamp(),
            'host' => $event->getHost(),
            'type' => $event->getType()
        ]);
    }
183595
public function getErrorsAsString(): string
    {
        $errors = $this->getErrors();
        if (0 === $errors->count()) {
            return '';
        }
        $message = 'found ' . $errors->count() . ' errors validating '
                   . \get_class($this->dataObject);
        foreach ($errors as $error) {
            $message .= "\n\n" . $error->getPropertyPath() . ': ' . $error->getMessage();
        }

        return $message;
    }
38437
public function col_time($event) {

        if (empty($this->download)) {
            $dateformat = get_string('strftimedatetime', 'core_langconfig');
        } else {
            $dateformat = get_string('strftimedatetimeshort', 'core_langconfig');
        }
        return userdate($event->timecreated, $dateformat);
    }
858997
function makeEventError(error) {
  var stack = error.stack.split('\n');

  stack.splice(0, 1);
  stack.forEach(function(s, i) {
    stack[i] = s.trim();
  });

  return {
    type: typeName(error),
    error: error.message,
    stack: stack.filter(function(s) {
      return s;
    })
  };
}
723814
public function col_course($event) {
        if (empty($event->courseid) || empty($this->courseshortnames[$event->courseid])) {
            return '-';
        } else {
            return $this->courseshortnames[$event->courseid];
        }
    }
353767
public static function dumpAssets(Event $event)
    {
        $options = self::getOptions($event);
        $consoleDir = static::getConsoleDir($event, 'install assets');

        if (null === $consoleDir) {
            return;
        }

        $webDir = $options['symfony-web-dir'];
        $command = 'assetic:dump';

        // if not set falls back to default behaviour of console commands (using SYMFONY_ENV or fallback to 'dev')
        if (!empty($options['ezpublish-asset-dump-env'])) {
            $event->getIO()->write('<error>Use of `ezpublish-asset-dump-env` is deprecated, use SYMFONY_ENV to set anything other then dev for all commands</error>');

            if ($options['ezpublish-asset-dump-env'] === 'none') {
                // If asset dumping is skipped, output help text on how to generate it if needed
                return self::dumpAssetsHelpText($event);
            }

            $command .= ' --env=' . escapeshellarg($options['ezpublish-asset-dump-env']);
        }

        if (!is_dir($consoleDir)) {
            echo 'The symfony console directory (' . $consoleDir . ') specified in composer.json was not found in ' . getcwd() . ', can not install assets.' . PHP_EOL;

            return;
        }

        if (!is_dir($webDir)) {
            echo 'The symfony-web-dir (' . $webDir . ') specified in composer.json was not found in ' . getcwd() . ', can not install assets.' . PHP_EOL;

            return;
        }

        static::executeCommand($event, $consoleDir, $command . ' ' . escapeshellarg($webDir));
    }