Hi Randy, On Oct 19, 2011, at 10:19 PM, Randy Fischer wrote:
> On Wed, Oct 19, 2011 at 3:38 PM, Rhett Sutphin > <[email protected]> wrote: >> Hi, >> >> I'd like to have my DataMapper-based system log to a file with a custom >> format (specifically, I'd like to include the clock time on each log >> message) and do daily log rotation. The built-in logger in Ruby can do these >> two things, but DataMapper::Logger can't, AFAICT. I've looked for a way to >> substitute the built-in logger for DataMapper's, but that doesn't seem to be >> possible. Googling has given me no suggestions. Any ideas? > > > It turns out to be pretty easy. Assuming you have some object with a write > method, just make the following call before you do any other datamapper > setup: > > DataMapper::Logger.new(my_logger, :debug) > > my_logger can then do whatever you want with the strings datamapper > sends to its write method. > > I use log4r for the heavy lifting myself. I've never realy used the built-in > logger in Ruby, so I don't know if its easier to extend it with a custom > write method, or just wrap it up in your own class (that's what I do with > log4r). I think you'd have to do something like this with the built-in logger as well. (It provides a << method, but not a write method.) I was wondering if there was a more natural solution, but I guess not. Thanks for the suggestion. Rhett > > Does that make any kind of sense? > > -Randy Fischer > > -- > 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. > -- 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.
