Where exactly the Logger is called? (trying to use Logging library)

5 views
Skip to first unread message

Iñaki Baz Castillo

unread,
Sep 1, 2009, 3:59:43 PM9/1/09
to DataMapper
Hi, I'm developing a server using DataMapper but I use Logging as
logger for the whole application. I want to avoid using
DataMapper::Logger resource as if I use it I should log database logs
to other file.

I want to find out where the DataMapper::Logger is called. For
example, if I configure DataMapper::Logger with level "info" then the
SQL queries would be logged to the configured file (or STDOUT).
However I don't find in dm-core library where exactly the logger is
invoked to write out the SQL query.

By searching the API I understand that #push or #<< are used for this
purpose, but doing a "grep" in the source code I can't find it.

What I want is to inspect where exactly the logger is called by
DataMapper and try to replace it with my already configured Logging
library to have unified logs. Could I know where and how exactly the
Logger is invoked? Any experience or tip to make DataMapper using
Logging library?

Thanks a lot.

PS: I read in the roadmap that replacing current DataMapper::Logger
with Logging is planed, any new about it?

Jordan Ritter

unread,
Sep 1, 2009, 6:10:00 PM9/1/09
to datam...@googlegroups.com

I do the same thing: "::DataMapper.logger = Logger.new(...)" (DM
0.10x) before calling ::DataMapper::setup, in order to catch all
logging that it might emit.

I think the "push/<<" Logger methods you're looking for are in Extlib
(which DM uses), which I believe was originally copied from Merb.
Some of the actual log emissions might also be happening in
DataObjects (haven't looked).

cheers,
--jordan

Iñaki Baz Castillo

unread,
Sep 2, 2009, 4:32:10 PM9/2/09
to datam...@googlegroups.com
El Miércoles, 2 de Septiembre de 2009, Jordan Ritter escribió:
> I do the same thing: "::DataMapper.logger = Logger.new(...)" (DM
> 0.10x) before calling ::DataMapper::setup, in order to catch all
> logging that it might emit.

So, it just required to do that? In my case I use Logging (instead of Logger)
but it also allows "<<" method.


--
Iñaki Baz Castillo <i...@aliax.net>

Reply all
Reply to author
Forward
0 new messages