Skip to content

Commit

Permalink
Merge pull request #45057 from nextcloud/enh/noid/server-log
Browse files Browse the repository at this point in the history
feat(exception-template): allow to link to specific documentation for how to retreive server log
  • Loading branch information
szaimen authored May 15, 2024
2 parents 0ad77fa + cb646b2 commit bc013ef
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -2241,6 +2241,11 @@
*/
'upgrade.cli-upgrade-link' => '',

/**
* Allows to modify the exception server logs documentation link in order to link to a different documentation
*/
'documentation_url.server_logs' => '',

/**
* Set this Nextcloud instance to debugging mode
*
Expand Down
3 changes: 3 additions & 0 deletions core/templates/exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ function print_exception(Throwable $e, \OCP\IL10N $l): void {
<p><?php p($l->t('The server was unable to complete your request.')) ?></p>
<p><?php p($l->t('If this happens again, please send the technical details below to the server administrator.')) ?></p>
<p><?php p($l->t('More details can be found in the server log.')) ?></p>
<?php if (isset($_['serverLogsDocumentation']) && $_['serverLogsDocumentation'] !== ''): ?>
<p><a href="<?php print_unescaped($_['serverLogsDocumentation']) ?>" target="_blank" rel="noopener"><?php p($l->t('For more details see the documentation ↗.')) ?></a></p>
<?php endif; ?>

<h3><?php p($l->t('Technical details')) ?></h3>
<ul>
Expand Down
2 changes: 2 additions & 0 deletions lib/private/legacy/OC_Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ public static function printExceptionErrorPage($exception, $statusCode = 503) {
http_response_code($statusCode);
try {
$debug = \OC::$server->getSystemConfig()->getValue('debug', false);
$serverLogsDocumentation = \OC::$server->getSystemConfig()->getValue('documentation_url.server_logs', '');
$request = \OC::$server->getRequest();
$content = new \OC_Template('', 'exception', 'error', false);
$content->assign('errorClass', get_class($exception));
Expand All @@ -315,6 +316,7 @@ public static function printExceptionErrorPage($exception, $statusCode = 503) {
$content->assign('line', $exception->getLine());
$content->assign('exception', $exception);
$content->assign('debugMode', $debug);
$content->assign('serverLogsDocumentation', $serverLogsDocumentation);
$content->assign('remoteAddr', $request->getRemoteAddress());
$content->assign('requestID', $request->getId());
$content->printPage();
Expand Down

0 comments on commit bc013ef

Please sign in to comment.