如何为每一行执行提供ruby logger日志? [英] How can I have ruby logger log for each line of execution?

查看:102
本文介绍了如何为每一行执行提供ruby logger日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对红宝石非常陌生,刚刚开始学习如何使用黄瓜和小黄瓜进行自动化。
我想将每个动作捕获到日志中!!!

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

谢谢
Ashok Natarajan

Thanks Ashok Natarajan

推荐答案

在黄瓜中记录事物的最简单方法是使用简单的puts语句。如果您不希望它显示在报告中,则可以使用kernel.puts

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

我也使用pry进行实时调试,如下所示:
http://www.alanmacdougall.com/blog/ 2012/06/08 / interactive-debugging-with-pry /

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

您还必须记住从所使用的宝石中收集所有输出。例如,如果您使用续集gem,则可能要记录数据库语句。您可以使用

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)

这篇关于如何为每一行执行提供ruby logger日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆