aboutsummaryrefslogtreecommitdiff
path: root/app/Models
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2017-12-10 21:31:41 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2017-12-10 21:58:24 +0100
commitb1c317a253445a6458f1263c1b622a788cc7cd0e (patch)
treed348ddbc62a98e53b50ca29cba352640b1aeb54d /app/Models
parent452886ea3ac4b91bc72952df659fb53ae7807c22 (diff)
Log rotation, use Minz_Log, new log constants
ADMIN_LOG, API_LOG, PSHB_LOG
Diffstat (limited to 'app/Models')
-rw-r--r--app/Models/Feed.php14
-rw-r--r--app/Models/LogDAO.php6
2 files changed, 9 insertions, 11 deletions
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, '');
}
}
}