Reputation: 10092
I have some Ruby code that I am testing stand alone before integrating into a Rails app. Because the final app. is in Rails I have numerous calls to Rails.logging.xxx that I want in there, but with these I can't run the stand alone app because it doesn't know about Rails.logging. How can I set it up so I can have these logging calls both in my CLI test app. and work in the final Rails deployment?
TY, Fred
Upvotes: 0
Views: 72
Reputation: 11821
why you cant use the logger in your app? just use it like an normal debugger?
see http://ruby.about.com/od/tasks/a/logger.htm
Upvotes: 0
Reputation: 34328
Why not just create a simple stub logger that is only available in the CLI version? For example:
class Rails
def self.logger
@logger ||= Logger.new('cli_logger.log')
end
end
Rails.logger.info("Spam")
Or perhaps more Rails-like:
class Rails
cattr_accessor :logger
end
Rails.logger = Logger.new('cli_logger.log')
Rails.logger.info("It works")
Upvotes: 3