Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic logging of DataMapper queries

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?

like image 350
kEND Avatar asked Oct 24 '09 20:10

kEND


1 Answers

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.

like image 143
kEND Avatar answered Oct 07 '22 21:10

kEND