LoginSignup
2
0

More than 5 years have passed since last update.

logger.xxxx で .inspect を使うと 1行でオブジェクトの中身を出力できる

Posted at

毎回、to_s や @u.id, @u.name …と列記しなくても、
@hoge.inspect 一行で中身を全部出力してくれる

コード例

hoge.rb
 @u = User.find(1)  #id:1, name:test, create_at:2000-01-01 00:00:00
 logger.debug @u.inspect

出力例

#<User id: 1, name: "test", create_at:"2000-01-01 00:00:00">

環境

  • productionモード以外

ログレベル

  • logger.fatal
  • logger.error
  • logger.warn
  • logger.info
  • logger.debug
2
0
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
2
0