mirror of https://github.com/FreshRSS/FreshRSS.git
Improved: error page (#4465)
* error page: true HTML page * error page: http500 erorr * error page: add CSP header * 'log.txt' replaced by LOG_FILENAME * use ADMIN_LOG * log.txt => LOG_FILENAME * error message: add <title> * Docs created * delete: documentation on error message page * line break added * added: new line at the end * typo fixed * Update lib/lib_rss.php Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> * Update lib/lib_rss.php Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr> * Minz HTTP 500 Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
This commit is contained in:
parent
85991d1c5c
commit
4214954ea1
|
@ -100,7 +100,7 @@ class FreshRSS_Context {
|
|||
$user_conf = Minz_Configuration::get('user');
|
||||
FreshRSS_Context::$user_conf = $user_conf;
|
||||
} catch (Exception $ex) {
|
||||
Minz_Log::warning($ex->getMessage(), USERS_PATH . '/_/log.txt');
|
||||
Minz_Log::warning($ex->getMessage(), USERS_PATH . '/_/' . LOG_FILENAME);
|
||||
}
|
||||
}
|
||||
if (FreshRSS_Context::$user_conf == null) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class FreshRSS_LogDAO {
|
||||
public static function lines() {
|
||||
$logs = array();
|
||||
$handle = @fopen(join_path(DATA_PATH, 'users', Minz_Session::param('currentUser', '_'), 'log.txt'), 'r');
|
||||
$handle = @fopen(join_path(DATA_PATH, 'users', Minz_Session::param('currentUser', '_'), LOG_FILENAME), 'r');
|
||||
if ($handle) {
|
||||
while (($line = fgets($handle)) !== false) {
|
||||
if (preg_match('/^\[([^\[]+)\] \[([^\[]+)\] --- (.*)$/', $line, $matches)) {
|
||||
|
@ -20,7 +20,7 @@ class FreshRSS_LogDAO {
|
|||
}
|
||||
|
||||
public static function truncate() {
|
||||
file_put_contents(join_path(DATA_PATH, 'users', Minz_Session::param('currentUser', '_'), 'log.txt'), '');
|
||||
file_put_contents(join_path(DATA_PATH, 'users', Minz_Session::param('currentUser', '_'), LOG_FILENAME), '');
|
||||
if (FreshRSS_Auth::hasAccess('admin')) {
|
||||
file_put_contents(ADMIN_LOG, '');
|
||||
file_put_contents(API_LOG, '');
|
||||
|
|
|
@ -83,9 +83,9 @@ foreach ($users as $user) {
|
|||
$app->run();
|
||||
|
||||
if (!invalidateHttpCache()) {
|
||||
Minz_Log::warning('FreshRSS write access problem in ' . join_path(USERS_PATH, $user, 'log.txt'), ADMIN_LOG);
|
||||
Minz_Log::warning('FreshRSS write access problem in ' . join_path(USERS_PATH, $user, LOG_FILENAME), ADMIN_LOG);
|
||||
if (defined('STDERR')) {
|
||||
fwrite(STDERR, 'FreshRSS write access problem in ' . join_path(USERS_PATH, $user, 'log.txt') . "\n");
|
||||
fwrite(STDERR, 'FreshRSS write access problem in ' . join_path(USERS_PATH, $user, LOG_FILENAME) . "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,8 @@ defined('DATA_PATH') or define('DATA_PATH', FRESHRSS_PATH . '/data');
|
|||
|
||||
defined('UPDATE_FILENAME') or define('UPDATE_FILENAME', DATA_PATH . '/update.php');
|
||||
defined('USERS_PATH') or define('USERS_PATH', DATA_PATH . '/users');
|
||||
defined('ADMIN_LOG') or define('ADMIN_LOG', USERS_PATH . '/_/log.txt');
|
||||
defined('LOG_FILENAME') or define('LOG_FILENAME', 'log.txt');
|
||||
defined('ADMIN_LOG') or define('ADMIN_LOG', USERS_PATH . '/_/' . LOG_FILENAME);
|
||||
defined('API_LOG') or define('API_LOG', USERS_PATH . '/_/log_api.txt');
|
||||
defined('CACHE_PATH') or define('CACHE_PATH', DATA_PATH . '/cache');
|
||||
defined('PSHB_LOG') or define('PSHB_LOG', USERS_PATH . '/_/log_pshb.txt');
|
||||
|
|
|
@ -2,9 +2,12 @@
|
|||
|
||||
Learn how to install, update, and backup FreshRSS, as well as how to use the command line tools.
|
||||
|
||||
## System Basics
|
||||
|
||||
1. [Prerequisites](02_Prerequisites.md): What you’ll need to run FreshRSS
|
||||
2. [General installation instructions](03_Installation.md) for FreshRSS
|
||||
3. [Update your installation](04_Updating.md) to the latest stable or development version
|
||||
4. [Logging and error messages](logs_and_errors.md) in case of any troubles
|
||||
|
||||
## Tutorials and Examples
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
# Logging and Error Messages
|
||||
|
||||
## Read the Log
|
||||
|
||||
### Log in the Application
|
||||
|
||||
The log files are displayed in the config menu.
|
||||
|
||||
### Log as Text Files
|
||||
|
||||
FreshRSS logs are located in:
|
||||
* user related: `./FreshRSS/data/users/*/log.txt`
|
||||
* general/system related: `./FreshRSS/data/users/_/log.txt`
|
||||
|
||||
### More Logging Information
|
||||
|
||||
More logs can be generated by enabling `'environment' => 'development'` (default: `'production'`), in `./FreshRSS/data/config.php`
|
||||
|
||||
## Error Message
|
||||
|
||||
If there is an 'Application Problem' or 'Fatal Error', then a HTTP 500 error message is shown with more information.
|
||||
|
||||
## Often the Cause of Problems
|
||||
|
||||
A typical problem is wrong file permissions in the `./FreshRSS/data/` folder so make sure the Web server can write there and in sub-directories.
|
||||
|
||||
## Common locations for additional logs
|
||||
|
||||
Adapt names and paths according to your local setup.
|
||||
|
||||
* If using Docker: `docker logs -f freshrss`
|
||||
* To check Web server logs on a Linux system using systemd: `journalctl -xeu apache2` and if you are using php-fpm: `journalctl -xeu php-fpm`
|
||||
* Otherwise, Web server logs are typically located in `/var/log/apache2/` or similar
|
||||
* System logs may also contain relevant information in `/var/log/syslog`, or if using systemd: `sudo journalctl -xe`
|
||||
|
||||
Running the feed update script (with the same user and PHP version as your Web server) might provide other hints, e.g.: `sudo -u www-data /usr/bin/php ./FreshRSS/app/actualize_script.php`
|
||||
|
||||
## Help needed
|
||||
|
||||
see: [Report a bug](https://freshrss.github.io/FreshRSS/en/contributing.html)
|
|
@ -44,7 +44,7 @@ class Minz_FrontController {
|
|||
Minz_Request::forward ($url);
|
||||
} catch (Minz_Exception $e) {
|
||||
Minz_Log::error($e->getMessage());
|
||||
$this->killApp ($e->getMessage());
|
||||
self::killApp($e->getMessage());
|
||||
}
|
||||
|
||||
$this->dispatcher = Minz_Dispatcher::getInstance();
|
||||
|
@ -78,7 +78,7 @@ class Minz_FrontController {
|
|||
try {
|
||||
Minz_Log::error($e->getMessage());
|
||||
} catch (Minz_PermissionDeniedException $e) {
|
||||
$this->killApp ($e->getMessage ());
|
||||
self::killApp($e->getMessage());
|
||||
}
|
||||
|
||||
if ($e instanceof Minz_FileNotExistException ||
|
||||
|
@ -91,20 +91,21 @@ class Minz_FrontController {
|
|||
true
|
||||
);
|
||||
} else {
|
||||
$this->killApp($e->getMessage());
|
||||
self::killApp($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Permet d'arrêter le programme en urgence
|
||||
*/
|
||||
private function killApp ($txt = '') {
|
||||
* Kills the programme
|
||||
*/
|
||||
public static function killApp($txt = '') {
|
||||
header('HTTP 1.1 500 Internal Server Error', true, 500);
|
||||
if (function_exists('errorMessageInfo')) {
|
||||
//If the application has defined a custom error message function
|
||||
exit(errorMessageInfo('Application problem', $txt));
|
||||
die(errorMessageInfo('Application problem', $txt));
|
||||
}
|
||||
exit('### Application problem ###<br />' . "\n" . $txt);
|
||||
die('### Application problem ###<br />' . "\n" . $txt);
|
||||
}
|
||||
|
||||
private function setReporting() {
|
||||
|
|
|
@ -36,7 +36,7 @@ class Minz_Log {
|
|||
$username = '_';
|
||||
}
|
||||
if ($file_name == null) {
|
||||
$file_name = join_path(USERS_PATH, $username, 'log.txt');
|
||||
$file_name = join_path(USERS_PATH, $username, LOG_FILENAME);
|
||||
} else {
|
||||
$username = '_';
|
||||
}
|
||||
|
|
|
@ -508,7 +508,7 @@ function invalidateHttpCache($username = '') {
|
|||
Minz_Session::_param('touch', uTimeString());
|
||||
$username = Minz_Session::param('currentUser', '_');
|
||||
}
|
||||
$ok = @touch(DATA_PATH . '/users/' . $username . '/log.txt');
|
||||
$ok = @touch(DATA_PATH . '/users/' . $username . '/' . LOG_FILENAME);
|
||||
//if (!$ok) {
|
||||
//TODO: Display notification error on front-end
|
||||
//}
|
||||
|
@ -569,9 +569,9 @@ function get_user_configuration($username) {
|
|||
FRESHRSS_PATH . '/config-user.default.php');
|
||||
} catch (Minz_ConfigurationNamespaceException $e) {
|
||||
// namespace already exists, do nothing.
|
||||
Minz_Log::warning($e->getMessage(), USERS_PATH . '/_/log.txt');
|
||||
Minz_Log::warning($e->getMessage(), ADMIN_LOG);
|
||||
} catch (Minz_FileNotExistException $e) {
|
||||
Minz_Log::warning($e->getMessage(), USERS_PATH . '/_/log.txt');
|
||||
Minz_Log::warning($e->getMessage(), ADMIN_LOG);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -823,25 +823,16 @@ function errorMessageInfo($errorTitle, $error = '') {
|
|||
$details = "<pre>{$details}</pre>";
|
||||
}
|
||||
|
||||
header("Content-Security-Policy: default-src 'self'");
|
||||
|
||||
return <<<MSG
|
||||
<h1>{$errorTitle}</h1>
|
||||
<!DOCTYPE html><html><header><title>HTTP 500: {$errorTitle}</title></header><body>
|
||||
<h1>HTTP 500: {$errorTitle}</h1>
|
||||
{$message}
|
||||
{$details}
|
||||
<h2>Check the logs</h2>
|
||||
<p>FreshRSS logs are located in <code>./FreshRSS/data/users/*/log*.txt</code></p>
|
||||
<p><em>N.B.:</em> A typical problem is wrong file permissions in the <code>./FreshRSS/data/</code> folder
|
||||
so make sure the Web server can write there and in sub-directories.</p>
|
||||
<h3>Common locations for additional logs</h3>
|
||||
<p><em>N.B.:</em> Adapt names and paths according to your local setup.</p>
|
||||
<ul>
|
||||
<li>If using Docker: <code>docker logs -f freshrss</code></li>
|
||||
<li>To check Web server logs on a Linux system using systemd: <code>journalctl -xeu apache2</code>
|
||||
and if you are using php-fpm: <code>journalctl -xeu php-fpm</code></li>
|
||||
<li>Otherwise, Web server logs are typically located in <code>/var/log/apache2/</code> or similar</li>
|
||||
<li>System logs may also contain relevant information in <code>/var/log/syslog</code>, or if using systemd: <code>sudo journalctl -xe</code></li>
|
||||
</ul>
|
||||
<p>More logs can be generated by enabling <code>'environment' => 'development',</code> in <code>./FreshRSS/data/config.php</code></p>
|
||||
<p>Running the feed update script (with the same user and PHP version as your Web server) might provide other hints, e.g.:
|
||||
<code>sudo -u www-data /usr/bin/php ./FreshRSS/app/actualize_script.php</code></p>
|
||||
<hr />
|
||||
<small>For help see the documentation: <a href="https://freshrss.github.io/FreshRSS/en/admins/logs_and_errors.html" target="_blank">
|
||||
https://freshrss.github.io/FreshRSS/en/admins/logs_and_errors.html</a></small>
|
||||
</body></html>
|
||||
MSG;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ if (!file_exists($applied_migrations_path)) {
|
|||
require(LIB_PATH . '/http-conditional.php');
|
||||
$currentUser = Minz_Session::param('currentUser', '');
|
||||
$dateLastModification = $currentUser === '' ? time() : max(
|
||||
@filemtime(join_path(USERS_PATH, $currentUser, 'log.txt')),
|
||||
@filemtime(join_path(USERS_PATH, $currentUser, LOG_FILENAME)),
|
||||
@filemtime(join_path(DATA_PATH, 'config.php'))
|
||||
);
|
||||
if (httpConditional($dateLastModification, 0, 0, false, PHP_COMPRESSION, true)) {
|
||||
|
@ -64,7 +64,6 @@ if (!file_exists($applied_migrations_path)) {
|
|||
|
||||
if ($error) {
|
||||
syslog(LOG_INFO, 'FreshRSS Fatal error! ' . $error);
|
||||
Minz_Log::error($error);
|
||||
die(errorMessageInfo('Fatal error', $error));
|
||||
FreshRSS::killApp($error);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue