Permalink
Browse files

(Fixes issue 1306)

  • Loading branch information...
1 parent dc906bd commit b0eedd66e0cf49f851276ab1a4d569048f18b17e qiang.xue committed Jun 18, 2010
Showing with 11 additions and 10 deletions.
  1. +1 −0 CHANGELOG
  2. +7 −8 framework/logging/CEmailLogRoute.php
  3. +3 −2 framework/logging/CLogRoute.php
View
@@ -61,6 +61,7 @@ Version 1.1.3 to be released
- Enh #1286: Upgraded HTMLPurifier to v4.1.1 (Qiang)
- Enh #1289: Added support to allow using non-string values when calling CDbCriteria::compare() (Qiang)
- Enh #1290: Added cssClass to individual item in CDetailView (Qiang)
+- Enh #1306: Hide log route outputs when no messages are collected after filtering (Qiang)
- Enh: CActiveRecord::beforeFind event is now triggered in all cases including related models with both lazy and eager loading (Sam Dark, creocoder)
- Enh: Added support for using array-typed model attributes in active methods in CHtml (Qiang)
- Enh: Added beforeValidate, afterValidate, beforeValidateAttribute and afterValidateAttribute options to CActiveForm (Qiang)
@@ -23,21 +23,17 @@
class CEmailLogRoute extends CLogRoute
{
/**
- * Default email subject.
- */
- const DEFAULT_SUBJECT='Application Log';
- /**
* @var array list of destination email addresses.
*/
private $_email=array();
/**
* @var string email subject
*/
- private $_subject='';
+ private $_subject;
/**
* @var string email sent from address
*/
- private $_from='';
+ private $_from;
/**
* Sends log messages to specified email addresses.
@@ -49,8 +45,11 @@ protected function processLogs($logs)
foreach($logs as $log)
$message.=$this->formatLogMessage($log[0],$log[1],$log[2],$log[3]);
$message=wordwrap($message,70);
+ $subject=$this->getSubject();
+ if($subject===null)
+ $subject=Yii::t('yii','Application Log');
foreach($this->getEmails() as $email)
- $this->sendEmail($email,$this->getSubject(),$message);
+ $this->sendEmail($email,$subject,$message);
}
/**
@@ -61,7 +60,7 @@ protected function processLogs($logs)
*/
protected function sendEmail($email,$subject,$message)
{
- if(($from=$this->getSentFrom())!=='')
+ if(($from=$this->getSentFrom())!==null)
mail($email,$subject,$message,"From:{$from}\r\n");
else
mail($email,$subject,$message);
@@ -91,11 +91,12 @@ public function collectLogs($logger, $processLogs=false)
{
$logs=$logger->getLogs($this->levels,$this->categories);
$this->logs=empty($this->logs) ? $logs : array_merge($this->logs,$logs);
- if($processLogs && !empty($this->logs))
+ if($processLogs)
{
if($this->filter!==null)
Yii::createComponent($this->filter)->filter($this->logs);
- $this->processLogs($this->logs);
+ if(!empty($this->logs))
+ $this->processLogs($this->logs);
}
}

0 comments on commit b0eedd6

Please sign in to comment.