I'm writing a map/reduce operation with Mongoid 3.0. I'm trying to use the print
statement to debug the JS functions. This is a troubleshooting suggestion from the MongoDB docs, e.g.:
reduce = %Q{
function(user_id, timestamps) {
var max = 0;
timestamps.forEach(function(t) {
var diff = t.started_at - t.attempted_at;
if (diff > max) { max = diff; }
});
print(user_id + ', ' + max);
return max;
};
}
MyCollection.all.map_reduce(map, reduce).to_a
Unfortunately the output from the print
statement shows up neither on the console nor on the log--it seems that this is suppressed somewhere between the DB, the driver, Moped or any of the intervening layers. Is there a way to turn this on?
It turns out the print
statements logs to the MongoDB server log. On OSX, that is /usr/local/var/log/mongodb/mongo.log