diff --git a/Modules/feed/engine/RedisBuffer.php b/Modules/feed/engine/RedisBuffer.php index e10ee08c6..708b2a0fb 100644 --- a/Modules/feed/engine/RedisBuffer.php +++ b/Modules/feed/engine/RedisBuffer.php @@ -189,13 +189,12 @@ private function process_feed_buffer($feedid){ // process if there is data on buffer and no write lock from real data if ($len > 0 && !$this->checkLock($feedid,"write")) { $this->setLock($feedid,"read"); // set read lock - echo "Processing feed=$feedid len=$len :\n"; $this->log->info("process_buffer() engine=$engine feed=$feedid len=$len"); $lasttime=0; $range = 50000; // step range number of points to extract on each iteration 50k-100k is ok for ($i=$range; $i<=$len+$range; $i++) { - echo " Reading block $i\n"; + $this->log->info(" Reading block $i"); if ($i > $len) $range = $range-($i-$len); $i = $i + $range-1; $buf_item = $this->redis->zRange("feed:$feedid:buffer", 0, $range-1, true); @@ -218,13 +217,13 @@ private function process_feed_buffer($feedid){ $matchcnt++; } if ($matchcnt > 0) { - echo " Invoking post_bulk_save engine=" . $engine . "\n"; + $this->log->info(" Invoking post_bulk_save engine=" . $engine); $this->feed->EngineClass($engine)->post_bulk_save(); } - if ($range != $matchcnt) { echo "WARN: expected $range but found $matchcnt items\n"; } + if ($range != $matchcnt) { $this->log->info("WARN: expected $range but found $matchcnt items"); } $remcnt = $this->redis->zRemRangeByRank("feed:$feedid:buffer", 0, $range-1); // Remove processed range - if ($remcnt != $matchcnt) { echo "WARN: found $matchcnt but deleted $remcnt items\n"; } + if ($remcnt != $matchcnt) { $this->log->info("WARN: found $matchcnt but deleted $remcnt items"); } } } $this->removeLock($feedid,"read"); // remove read lock diff --git a/scripts/feedwriter.php b/scripts/feedwriter.php index 40a23202b..354633fc7 100644 --- a/scripts/feedwriter.php +++ b/scripts/feedwriter.php @@ -12,12 +12,12 @@ require "Lib/EmonLogger.php"; require "process_settings.php"; - if (!$redis_enabled) { echo "Error: setting must be true: redis_enabled\n"; die; } - if (!$feed_settings['redisbuffer']['enabled']) { echo "Error: setting must be true: feed_settings['redisbuffer']['enabled']\n"; die; } - if (!$feed_settings['redisbuffer']['sleep'] || (int)$feed_settings['redisbuffer']['sleep'] < 1) { echo "Error: setting must be > 0 : feed_settings['redisbuffer']['sleep']\n"; die; } - $log = new EmonLogger(__FILE__); $log->error("Starting feedwriter script"); + + if (!$redis_enabled) { $log->error("Error: setting must be true: redis_enabled"); die; } + if (!$feed_settings['redisbuffer']['enabled']) { $log->error("Error: setting must be true: feed_settings['redisbuffer']['enabled']"); die; } + if (!$feed_settings['redisbuffer']['sleep'] || (int)$feed_settings['redisbuffer']['sleep'] < 1) { $log->error("Error: setting must be > 0 : feed_settings['redisbuffer']['sleep']"); die; } $mysqli = @new mysqli($server,$username,$password,$database,$port); if ($mysqli->connect_error) { $log->error("Can't connect to database:". $mysqli->connect_error); die('Check log\n'); } @@ -49,7 +49,7 @@ $feed->EngineClass(Engine::REDISBUFFER)->removeLock($feedid,"write"); } - echo "Buffered feed writer daemon started with sleep " . $feed_settings['redisbuffer']['sleep'] . "s...\n"; + $log->info("Buffered feed writer daemon started with sleep " . $feed_settings['redisbuffer']['sleep'] . "s..."); while(true) { $feed->EngineClass(Engine::REDISBUFFER)->process_buffers();