Skip to content

Instantly share code, notes, and snippets.

@yonicd
Last active June 5, 2017 01:53
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 yonicd/8685569fa5ac4befc1ad032f79b71330 to your computer and use it in GitHub Desktop.
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
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