/** * Builds the log file entry for the given log message. * * TODO: Use localized time in local log files * * @param string $logLevel Log level of the message to log * @param string $message The message to log * @param \Exception|null $exception Exception belonging to the log entry * @return string */ private function buildLogEntry(string $logLevel, string $message, Exception $exception = null) { // build base log entry $logEntry = sprintf('%s %s %s', DateUtil::getCurrentUtcDateTime()->format('Y-m-d H:i:s'), StringUtil::toUpperCase($logLevel), $message); // add exception information if present if ($exception !== null) { $logEntry .= StringUtil::CHAR_LINE_FEED . sprintf('Exception: %s in file %s on line %s', $exception->getMessage(), $exception->getFile(), $exception->getLine()) . StringUtil::CHAR_LINE_FEED . ExceptionUtil::getFullTrace($exception); } // return log entry return $logEntry; }