问题描述
我正在使用DataMapper在Sinatra中开发一个简单的应用程序。我想查看为各种链式查找器等创建的DM查询。
I am working on a simple app in Sinatra with DataMapper. I want to see the queries that DM is created for my various chained finders, etc.
我尝试过:
DataMapper::Logger.new(STDOUT, :debug)
在我的配置中...结束
块中的 environment.rb
文件,该文件在应用启动时加载。
in my configure do ... end
block in an environment.rb
file that loads when the app is started.
我也尝试过:
DataMapper::Logger.new('log/my-app.log', :debug)
都不会从应用程序中生成日志语句通过浏览器或需要我的应用的 irb
会话访问。我确实看到了应用程序启动消息。
Neither yields log statements from the app accessed either through a browser or through an irb
session that requires my app. I do see the app starting message.
我正在使用 rackup config.ru
在本地运行该应用程序。
I am using rackup config.ru
to run the app locally.
我想念什么?
推荐答案
似乎我错过了完全合理的步骤。建立连接之前,需要放置 DataMapper :: Logger.new(STDOUT,:debug)
。 HT到#datamapper IRC上的@snusnu。
It seems that I missed a perfectly reasonable step. You need to place the DataMapper::Logger.new(STDOUT, :debug)
before you make the connection. HT to @snusnu on #datamapper IRC.
这篇关于自动记录DataMapper查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!