Rails: Logging for code in the lib directory?

前端 未结 2 1503
野的像风
野的像风 2021-01-31 14:48

What is the best/easiest way to configure logging for code kept in the lib directory?

2条回答
  •  有刺的猬
    2021-01-31 15:36

    We can use Rails logger directly into the lib, see the following snippet.

    require 'logger'
    
    Rails.logger.info "Hay..!!! Im in lib"
    Rails.logger.debug "Debugging this object from Lib #{object.inspect}"
    Rails.logger.error "This is an error..."
    

提交回复
热议问题