aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2017-12-11 19:58:09 +0100
committerGravatar GitHub <noreply@github.com> 2017-12-11 19:58:09 +0100
commit27c3092da42854772100101b3ba9a7507c86f3a1 (patch)
treef52125dd6429e0c2aee2112804feebf2e5f7b08d /app
parentc722b2cdb7a23ddd37e4cee8b612d4896139038d (diff)
parent3ddbff6bd91ae16edfe2259ebd1bea04c86c7601 (diff)
Merge pull request #1712 from kevinpapst/logfilesize
Prevent logfile from growing unlimited
Diffstat (limited to 'app')
-rwxr-xr-xapp/Controllers/feedController.php4
-rw-r--r--app/Models/Feed.php14
-rw-r--r--app/Models/LogDAO.php6
-rwxr-xr-xapp/actualize_script.php11
4 files changed, 15 insertions, 20 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 45cba9e98..883f7af05 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -263,7 +263,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
if ((!$simplePiePush) && (!$feed_id) && $pubSubHubbubEnabled && ($feed->lastUpdate() > $pshbMinAge)) {
//$text = 'Skip pull of feed using PubSubHubbub: ' . $url;
//Minz_Log::debug($text);
- //file_put_contents(USERS_PATH . '/_/log_pshb.txt', date('c') . "\t" . $text . "\n", FILE_APPEND);
+ //Minz_Log::debug($text, PSHB_LOG);
continue; //When PubSubHubbub is used, do not pull refresh so often
}
@@ -371,7 +371,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
if ($pubSubHubbubEnabled && !$simplePiePush) { //We use push, but have discovered an article by pull!
$text = 'An article was discovered by pull although we use PubSubHubbub!: Feed ' . $url . ' GUID ' . $entry->guid();
- file_put_contents(USERS_PATH . '/_/log_pshb.txt', date('c') . "\t" . $text . "\n", FILE_APPEND);
+ Minz_Log::warning($text, PSHB_LOG);
Minz_Log::warning($text);
$pubSubHubbubEnabled = false;
$feed->pubSubHubbubError(true);
diff --git a/app/Models/Feed.php b/app/Models/Feed.php
index 85273d3f7..75d9f6d6f 100644
--- a/app/Models/Feed.php
+++ b/app/Models/Feed.php
@@ -403,8 +403,7 @@ class FreshRSS_Feed extends Minz_Model {
if (!isset($hubJson['error']) || $hubJson['error'] !== (bool)$error) {
$hubJson['error'] = (bool)$error;
file_put_contents($hubFilename, json_encode($hubJson));
- file_put_contents(USERS_PATH . '/_/log_pshb.txt', date('c') . "\t"
- . 'Set error to ' . ($error ? 1 : 0) . ' for ' . $url . "\n", FILE_APPEND);
+ Minz_Log::warning('Set error to ' . ($error ? 1 : 0) . ' for ' . $url, PSHB_LOG);
}
return false;
}
@@ -419,7 +418,7 @@ class FreshRSS_Feed extends Minz_Model {
if (!$hubJson || empty($hubJson['key']) || !ctype_xdigit($hubJson['key'])) {
$text = 'Invalid JSON for PubSubHubbub: ' . $this->url;
Minz_Log::warning($text);
- file_put_contents(USERS_PATH . '/_/log_pshb.txt', date('c') . "\t" . $text . "\n", FILE_APPEND);
+ Minz_Log::warning($text, PSHB_LOG);
return false;
}
if ((!empty($hubJson['lease_end'])) && ($hubJson['lease_end'] < (time() + (3600 * 23)))) { //TODO: Make a better policy
@@ -427,7 +426,7 @@ class FreshRSS_Feed extends Minz_Model {
. date('c', empty($hubJson['lease_end']) ? time() : $hubJson['lease_end'])
. ' and needs renewal: ' . $this->url;
Minz_Log::warning($text);
- file_put_contents(USERS_PATH . '/_/log_pshb.txt', date('c') . "\t" . $text . "\n", FILE_APPEND);
+ Minz_Log::warning($text, PSHB_LOG);
$key = $hubJson['key']; //To renew our lease
} elseif (((!empty($hubJson['error'])) || empty($hubJson['lease_end'])) &&
(empty($hubJson['lease_start']) || $hubJson['lease_start'] < time() - (3600 * 23))) { //Do not renew too often
@@ -445,7 +444,7 @@ class FreshRSS_Feed extends Minz_Model {
file_put_contents(PSHB_PATH . '/keys/' . $key . '.txt', base64url_encode($this->selfUrl));
$text = 'PubSubHubbub prepared for ' . $this->url;
Minz_Log::debug($text);
- file_put_contents(USERS_PATH . '/_/log_pshb.txt', date('c') . "\t" . $text . "\n", FILE_APPEND);
+ Minz_Log::debug($text, PSHB_LOG);
}
$currentUser = Minz_Session::param('currentUser');
if (FreshRSS_user_Controller::checkUsername($currentUser) && !file_exists($path . '/' . $currentUser . '.txt')) {
@@ -499,9 +498,8 @@ class FreshRSS_Feed extends Minz_Model {
$response = curl_exec($ch);
$info = curl_getinfo($ch);
- file_put_contents(USERS_PATH . '/_/log_pshb.txt', date('c') . "\t" .
- 'PubSubHubbub ' . ($state ? 'subscribe' : 'unsubscribe') . ' to ' . $url .
- ' with callback ' . $callbackUrl . ': ' . $info['http_code'] . ' ' . $response . "\n", FILE_APPEND);
+ Minz_Log::warning('PubSubHubbub ' . ($state ? 'subscribe' : 'unsubscribe') . ' to ' . $url .
+ ' with callback ' . $callbackUrl . ': ' . $info['http_code'] . ' ' . $response, PSHB_LOG);
if (substr($info['http_code'], 0, 1) == '2') {
return true;
diff --git a/app/Models/LogDAO.php b/app/Models/LogDAO.php
index ab258cd58..5bce466d5 100644
--- a/app/Models/LogDAO.php
+++ b/app/Models/LogDAO.php
@@ -22,9 +22,9 @@ class FreshRSS_LogDAO {
public static function truncate() {
file_put_contents(join_path(DATA_PATH, 'users', Minz_Session::param('currentUser', '_'), 'log.txt'), '');
if (FreshRSS_Auth::hasAccess('admin')) {
- file_put_contents(join_path(DATA_PATH, 'users', '_', 'log.txt'), '');
- file_put_contents(join_path(DATA_PATH, 'users', '_', 'log_api.txt'), '');
- file_put_contents(join_path(DATA_PATH, 'users', '_', 'log_pshb.txt'), '');
+ file_put_contents(ADMIN_LOG, '');
+ file_put_contents(API_LOG, '');
+ file_put_contents(PSHB_LOG, '');
}
}
}
diff --git a/app/actualize_script.php b/app/actualize_script.php
index 0bb1f166f..6f48220a6 100755
--- a/app/actualize_script.php
+++ b/app/actualize_script.php
@@ -18,8 +18,6 @@ $_GET['ajax'] = 1;
$_GET['force'] = true;
$_SERVER['HTTP_HOST'] = '';
-$log_file = join_path(USERS_PATH, '_', 'log.txt');
-
$app = new FreshRSS();
$system_conf = Minz_Configuration::get('system');
@@ -42,13 +40,13 @@ $min_last_activity = time() - $limits['max_inactivity'];
foreach ($users as $user) {
if (($user !== $system_conf->default_user) &&
(FreshRSS_UserDAO::mtime($user) < $min_last_activity)) {
- Minz_Log::notice('FreshRSS skip inactive user ' . $user, $log_file);
+ Minz_Log::notice('FreshRSS skip inactive user ' . $user, ADMIN_LOG);
if (defined('STDOUT')) {
fwrite(STDOUT, 'FreshRSS skip inactive user ' . $user . "\n"); //Unbuffered
}
continue;
}
- Minz_Log::notice('FreshRSS actualize ' . $user, $log_file);
+ Minz_Log::notice('FreshRSS actualize ' . $user, ADMIN_LOG);
if (defined('STDOUT')) {
fwrite(STDOUT, 'Actualize ' . $user . "...\n"); //Unbuffered
}
@@ -63,15 +61,14 @@ foreach ($users as $user) {
if (!invalidateHttpCache()) {
- Minz_Log::notice('FreshRSS write access problem in ' . join_path(USERS_PATH, $user, 'log.txt'),
- $log_file);
+ Minz_Log::warning('FreshRSS write access problem in ' . join_path(USERS_PATH, $user, 'log.txt'), ADMIN_LOG);
if (defined('STDERR')) {
fwrite(STDERR, 'Write access problem in ' . join_path(USERS_PATH, $user, 'log.txt') . "\n");
}
}
}
-Minz_Log::notice('FreshRSS actualize done.', $log_file);
+Minz_Log::notice('FreshRSS actualize done.', ADMIN_LOG);
if (defined('STDOUT')) {
fwrite(STDOUT, 'Done.' . "\n");
$end_date = date_create('now');