The common approach to setup logging is the following (actually, that's the skeleton for any standalone snippet of dm code)
require 'rubygems' require 'dm-core' DataMapper.Logger.new($stdout, :debug) DataMapper.setup(:default, 'sqlite3:memory:') # some models and test code __END__ # the output of the script I will try to get that information onto the website. cheers snusnu On Tue, Oct 20, 2009 at 20:19, sliu <[email protected]> wrote: > > My requirement is simple: see SQLs generated by DM. > > After reading dm-core's FQA and deep google search, I only got several > outdated information, util I found this thread: > > http://groups.google.com/group/datamapper/browse_thread/thread/fa66b06e770862f2/2f31be41f3f9fe8c?lnk=gst&q=logger+sql#2f31be41f3f9fe8c > > From above link, the right answer is: > > require 'logger' > > # assign a standard logger explicitly, with debug level to trace SQL. > # and, these two line should be ahead of DataMapper.setup, otherwise, > SQL won't be ouput. Strange behavior, and I think it is a BUG? > > DataMapper.logger = Logger.new(STDOUT) > DataMapper.logger.level = Logger::DEBUG > > DataMapper.setup(:default, ......) > > > Could anyone help to update dm-core's FAQ and add it to official > documentation(datamapper.org)? > > I think it is important enough and may be used frequently. > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/datamapper?hl=en -~----------~----~----~----~------~----~------~--~---
