I have a small framework that is logging some info and debug messages using the Logger object built into ruby. At run time, this works great. At unit test time (using rspec if it matters...) i would like to dump the logged messages to an in memory string variable. What's the easiest way to go about doing this?
I was considering a monkey patch that would replace the info and debug methods, like this:
class Logger
def info msg
$logs = msg
super msg
end
end
is there a better way to go about sending my log messages to a string variable?