I want to pass the console.log function to my view in Node Express, I've tried:
res.render('index', {
"title" : 'My page',
"logger": console.log
}
I've also tried this
res.render('index', {
"title" : 'My page',
"logger": function () {
console.log(arguments);
}
}
But it always comes through as empty, am I missing something?
fwiw this is how I'm trying to output it in my view
script
log = #{logger};
For those that want to know the why
I develop on my iPad 2 while on the move (it's jailbroken) and Apple in their wisdom remove the develop toolbar in recent versions so I'm stuck with alerts which are just awful so I want a makeshift console.log to my terminal instead.
[EDIT]
If I used Socket I/O
I could subscribe on the backend to a "log" event on the front end and emit these events and data to console log.
I've not put this as an answer because I don't think it's the best way but this would work I think.