Skip to content

Instantly share code, notes, and snippets.

@ghostoy
Created December 18, 2015 06:48
Show Gist options
  • Save ghostoy/789092f37bc3bb5989d1 to your computer and use it in GitHub Desktop.
Save ghostoy/789092f37bc3bb5989d1 to your computer and use it in GitHub Desktop.
Console in Node context should redirect output to DevTools
exports.log = function(msg) {
console.log(msg);
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>security</title>
</head>
<body>
Open DevTools by F12 or Cmd+Option+i (Mac) and click <button onclick="doLog()"></button>. You should see "hello" in the console.
<script>
function doLog() {
nw.require('./console').log('hello');
}
</script>
</body>
</html>
{
"name": "console-redirect",
"main": "index.html"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment