From 3b4c46e039785b4b9cf40dd477321853a1638be7 Mon Sep 17 00:00:00 2001 From: Corey Ballou Date: Thu, 21 Feb 2013 07:37:16 -0500 Subject: [PATCH] Fixed the Resque_Worker log method to properly handle NORMAL vs VERBOSE logging. --- lib/Resque/Worker.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/Resque/Worker.php b/lib/Resque/Worker.php index 5dc678d..45852bb 100644 --- a/lib/Resque/Worker.php +++ b/lib/Resque/Worker.php @@ -169,7 +169,7 @@ class Resque_Worker break; } // If no job was found, we sleep for $interval before continuing and checking again - $this->log('Sleeping for ' . $interval, true); + $this->log('Sleeping for ' . $interval, self::LOG_VERBOSE); if($this->paused) { $this->updateProcLine('Paused'); } @@ -517,16 +517,21 @@ class Resque_Worker /** * Output a given log message to STDOUT. * - * @param string $message Message to output. + * @param string $message Message to output. + * @param int $logLevel The logging level to capture */ - public function log($message) + public function log($message, $logLevel = self::LOG_NORMAL) { - if($this->logLevel == self::LOG_NORMAL) { + if ($logLevel > $this->logLevel) { + return; + } + + if ($this->logLevel == self::LOG_NORMAL) { fwrite(STDOUT, "*** " . $message . "\n"); + return; } - else if($this->logLevel == self::LOG_VERBOSE) { - fwrite(STDOUT, "** [" . strftime('%T %Y-%m-%d') . "] " . $message . "\n"); - } + + fwrite(STDOUT, "** [" . strftime('%T %Y-%m-%d') . "] " . $message . "\n"); } /**