在Hubot脚本中debugging/打印

我试图debugging一个现有的Hubot脚本,并在将来写我自己的,我需要一个简单的方法来debugging它,或至less打印值的地方(但不是渠道)。 我怎么能这样做?

如果在一些交互式本地模式下仅使用Node,就可以实现奖励点。 我真的不知道从哪里开始。

Hubot使用的所有脚本都是用Coffeescript编写的。

PS我和Hipchat一起使用Hubot。

我不知道这是否有帮助,但我find了一种方法来检查对象。

Util = require "util" module.exports = (robot) -> robot.hear /hi robot/i, (msg) -> user = robot.brain.usersForFuzzyName(msg.message.user.name) msg.send "#{Util.inspect(user)}" 

这可以看到对象的所有元素,所以我可以弄清楚我做错了什么…

我自己发现了答案: console.log MSG .coffee Coffeescript源代码中的console.log MSG正是我所需要的。

您可以使用

 robot.logger.info "your log message here" 

这将logging它就像logging其他hubot消息。

find这个(coffeescript)片段的地方logging所有的错误,相当有助于添加到机器人的发展。

robot.error (err, res) -> robot.logger.error "#{err}\n#{err.stack}" if res? res.reply "#{err}\n#{err.stack}"