Skip to content

Instantly share code, notes, and snippets.

@wheresrhys
Last active February 5, 2016 10:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wheresrhys/bf93057ee3a594454582 to your computer and use it in GitHub Desktop.
Save wheresrhys/bf93057ee3a594454582 to your computer and use it in GitHub Desktop.
console.log in legacy devices
// app.js
app.get('/article/log', function (req, res, next) {
console.log.apply(console, ['------------------------------\nClient log:'].concat(JSON.parse(req.query.messages), ['\n------------------------------']));
});
// client.js
window.console = window.console || {};
window.console.log = function (...messages) {
fetch && fetch(`/article/log?messages=${JSON.stringify(messages)}`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment