Automatic logging of DataMapper queries

自闭症网瘾萝莉.ら 提交于 2019-12-20 10:32:16

问题


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.

I have tried:

DataMapper::Logger.new(STDOUT, :debug)

in my configure do ... end block in an environment.rb file that loads when the app is started.

I have also tried:

DataMapper::Logger.new('log/my-app.log', :debug)

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.

I am using rackup config.ru to run the app locally.

What am I missing?


回答1:


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.



来源:https://stackoverflow.com/questions/1619028/automatic-logging-of-datamapper-queries

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