1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Railsでメソッド呼び出し元をログに出力する

Last updated at Posted at 2015-11-10

このメソッドどこから呼ばれてるんだって調べるときにはPryを使ったりするかも知れませんが、大量に呼ばれたりしてるといちいち止めていられません。そこでログに呼び出し元を吐き出して後から調べるということをしてみたくなった時のための方法。

Logger.new('log/hogehoge.log').debug caller[0]

これを呼び出し元を調べたいメソッドに仕込んでおくと指定したlogファイルに直近の呼び出し元が書かれていくので後で調べていくのに便利です。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?