Commit b3382404 by Tobias Munk Committed by Carsten Brandt

added check for undefined application to log Target

allows using logger without a Yii application now. close #6739
parent ee85dba9
......@@ -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)
......
......@@ -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() : '-';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment