added check for undefined application to log Target

allows using logger without a Yii application now.

close #6739
This commit is contained in:
Tobias Munk
2015-01-03 19:03:19 +01:00
committed by Carsten Brandt
parent ee85dba92e
commit b33824044f
2 changed files with 5 additions and 0 deletions

View File

@ -20,6 +20,7 @@ Yii Framework 2 Change Log
- Enh #6467: `ActiveForm` will scroll to the nearest visible element when the first error input is hidden (newartix)
- Enh #6488: Support changing `yii\base\Theme::basePath` during runtime (qiangxue)
- Enh #6618: Added Model::addErrors() (slavcodev, pana1990)
- Enh #6739: Log `Target` now works also when there is no `Yii::$app` instance available, no message prefix will be added in this case (schmunk42)
- Chg #6427: In case of invalid route web application now throws exception with "Page not found" instead of "Invalid Route" (cebe, samdark)
- Chg #6641: removed zero padding from ETag strings (DaSourcerer)
- Chg #6678: `yii\behaviors\SluggableBehavior` will generate a new slug only when the slug attribute is empty or the source attribute is changed (qiangxue)

View File

@ -266,6 +266,10 @@ abstract class Target extends Component
return call_user_func($this->prefix, $message);
}
if (Yii::$app === null) {
return '';
}
$request = Yii::$app->getRequest();
$ip = $request instanceof Request ? $request->getUserIP() : '-';