Created
December 18, 2015 06:48
-
-
Save ghostoy/789092f37bc3bb5989d1 to your computer and use it in GitHub Desktop.
Console in Node context should redirect output to DevTools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.log = function(msg) { | |
console.log(msg); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "console-redirect", | |
"main": "index.html" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment