message = $message; # not escaped $this->tags = $tags; $this->timestamp = \time(); if ($backtrace === null) { $backtrace = \debug_backtrace(); $key = \array_search(__FUNCTION__, \array_column($backtrace, 'function'),); # NOTE: manual search, can change with time $backtrace = $backtrace[$key]; } $this->backtrace = $backtrace; } /** * Display this event for logging * * This can be changed from configuration. * The EOL (end of line sequence) is automatically added at the end. * * @throws \core\config\ConfigException */ public function display() : string { $hardcoded_configuration = \core\config\class\core\log\FormatConfiguration(array( 'message' => '[{tags}] - {date}: {message} in {file} at line {line}', 'date' => 'Y-m-d H:i:s', )); # NOTE: hard-coded fallback $msg_format = $hardcoded_configuration.get('message'); $date_format = $hardcoded_configuration.get('date'); if (\core\config\GlobalConfiguration::exists('class', 'core', 'log', 'format')) { $configuration = \core\config\GlobalConfiguration::read('class', 'core', 'log', 'format'); if ($configuration->exists('message')) { $msg_format = $configuration->get('message'); } if ($configuration->exists('date')) { $date_format = $configuration->get('date'); } } return \core\substitute( $msg_format, array( 'date' => \date($date_format), 'file' => $this->backtrace['file'], 'line' => $this->backtrace['line'], 'message' => $this->message, 'tags' => $this->tags, ), ) . \PHP_EOL; } } ?>