LoginSignup
5
4

More than 5 years have passed since last update.

[laravel]超楽debug出力

Last updated at Posted at 2018-02-08

For

ログ出力時に、変数の値だけじゃなくてmethodName変数名を出力したい...けどいちいち書きたくないひとへ

これ

...
function getMethodName(){

 $data = 200;
 logger(__method__ ,compact('data'));
}
...
// [2018-02-08 12:03:37] local.DEBUG: App\Libs\CartsUtil::getMethodName {"data":200} 

要点

  • __method__ : メソッド名の取得
  • compact() : 変数を配列型にパッキングして渡せる
  • logger : 第二引数は配列を渡す。compact()を使わないときは [$data]とするとよし

...
この方法に気づいて感動したので皆さんに共有。

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4