Last active
June 5, 2017 01:53
-
-
Save yonicd/8685569fa5ac4befc1ad032f79b71330 to your computer and use it in GitHub Desktop.
show active console with log, warnings and errors during within widget during widget run
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
library(htmltools) | |
browsable( | |
tagList( | |
tags$pre(id="myPreview"), | |
tags$script(" | |
var log = document.querySelector('#myPreview'); | |
['log','debug','info','warn','error'].forEach(function (verb) { | |
console[verb] = (function (method, verb, log) { | |
return function () { | |
method.apply(console, arguments); | |
var msg = document.createElement('div'); | |
msg.classList.add(verb); | |
msg.textContent = verb + ': ' + Array.prototype.slice.call(arguments).join(' '); | |
log.appendChild(msg); | |
}; | |
})(console[verb], verb, log); | |
}); | |
console.log('test') | |
" | |
), | |
rmarkdown::html_dependency_jquery() | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment