Permalink
Browse files

Fixed the Resque_Worker log method to properly handle NORMAL vs VERBO…

…SE logging.
  • Loading branch information...
1 parent 9b45f15 commit 3b4c46e039785b4b9cf40dd477321853a1638be7 @cballou cballou committed Feb 21, 2013
Showing with 12 additions and 7 deletions.
  1. +12 −7 lib/Resque/Worker.php
View
@@ -169,7 +169,7 @@ public function work($interval = 5)
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 @@ public function __toString()
/**
* 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) {
- fwrite(STDOUT, "*** " . $message . "\n");
+ if ($logLevel > $this->logLevel) {
+ return;
}
- else if($this->logLevel == self::LOG_VERBOSE) {
- fwrite(STDOUT, "** [" . strftime('%T %Y-%m-%d') . "] " . $message . "\n");
+
+ if ($this->logLevel == self::LOG_NORMAL) {
+ fwrite(STDOUT, "*** " . $message . "\n");
+ return;
}
+
+ fwrite(STDOUT, "** [" . strftime('%T %Y-%m-%d') . "] " . $message . "\n");
}
/**

0 comments on commit 3b4c46e

Please sign in to comment.