Skip to content

Commit c18b544

Browse files
committed
Merge pull request #90 from cballou/master
Fixed Resque_Worker logging as it would always output verbose messaging.
2 parents 9b45f15 + 3b4c46e commit c18b544

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

lib/Resque/Worker.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ public function work($interval = 5)
169169
break;
170170
}
171171
// If no job was found, we sleep for $interval before continuing and checking again
172-
$this->log('Sleeping for ' . $interval, true);
172+
$this->log('Sleeping for ' . $interval, self::LOG_VERBOSE);
173173
if($this->paused) {
174174
$this->updateProcLine('Paused');
175175
}
@@ -517,16 +517,21 @@ public function __toString()
517517
/**
518518
* Output a given log message to STDOUT.
519519
*
520-
* @param string $message Message to output.
520+
* @param string $message Message to output.
521+
* @param int $logLevel The logging level to capture
521522
*/
522-
public function log($message)
523+
public function log($message, $logLevel = self::LOG_NORMAL)
523524
{
524-
if($this->logLevel == self::LOG_NORMAL) {
525-
fwrite(STDOUT, "*** " . $message . "\n");
525+
if ($logLevel > $this->logLevel) {
526+
return;
526527
}
527-
else if($this->logLevel == self::LOG_VERBOSE) {
528-
fwrite(STDOUT, "** [" . strftime('%T %Y-%m-%d') . "] " . $message . "\n");
528+
529+
if ($this->logLevel == self::LOG_NORMAL) {
530+
fwrite(STDOUT, "*** " . $message . "\n");
531+
return;
529532
}
533+
534+
fwrite(STDOUT, "** [" . strftime('%T %Y-%m-%d') . "] " . $message . "\n");
530535
}
531536

532537
/**

0 commit comments

Comments
 (0)