Automatic logging of DataMapper queries

2019-03-12 12:27发布

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条回答
Juvenile、少年°
2楼-- · 2019-03-12 13:25

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.

查看更多
登录 后发表回答