How can I have ruby logger log for each line of execution?

眉间皱痕 提交于 2019-12-11 18:03:43

问题


I am very new to ruby, just started learning for doing a automation with cucumber and Gherkin. I wanted to capture the each and every action into the logs!!!

Is there a way to capture!!! Thanks for your advice in advance!!!

Thanks Ashok Natarajan


回答1:


The easiest way to log things in cucumber is using simple puts statements. if you don't want it to show up in the reports you could use kernel.puts

I have also used pry for real time debugging like this: http://www.alanmacdougall.com/blog/2012/06/08/interactive-debugging-with-pry/

You must also remember to gather any output from gems that you are using. For example if you use the sequel gem you will probably want to log the database statements. you could use something like

require 'logger'
DB.loggers << Logger.new($stdout)



回答2:


If your question is about cucumber logging, check out the man page for available options. Try:

cucumber -v -b -x

-b, --backtrace Show full backtrace for all errors.

-v, --verbose Show the files and features loaded.

-x, --expand Expand Scenario Outline Tables in output.



来源:https://stackoverflow.com/questions/29146107/how-can-i-have-ruby-logger-log-for-each-line-of-execution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!