
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
console-log-html
Advanced tools
A tiny library that overrides the browser's console.* functions allowing the logged messages to be displayed in HTML.
Migrating from 1.x to 2.0? See MIGRATING.md
Simply include the file on your page:
<script type="application/javascript" src="console-log-html.min.js"></script>
<!-- Or, alternatively, use the CDN URL -->
<script type="application/javascript" src="//cdn.rawgit.com/Alorel/console-log-html/master/console-log-html.min.js"></script>
It can also be included as a dependency from npm:
npm install console-log-html --save
(function(){ // Your closure
var ConsoleLogHTML = require('console-log-html');
})();
<ul id="myULContainer"></ul> <!-- I will hold the log messages -->
<script type="application/javascript" src="console-log-html.min.js"></script>
<script>
ConsoleLogHTML.connect(document.getElementById("myULContainer")); // Redirect log messages
ConsoleLogHTML.disconnect(); // Stop redirecting
</script>
You can also instruct the script to only log to the console by passing a second argument to console.*(), e.g.:
console.log("foo"); // Logs "foo" to HTML
console.log("Look, some JSON:", {foo: 'bar'}); // Logs "Look, some JSON: Object {"foo":"bar"}" to HTML
console.skipHtml.log("bar"); // Logs only to the console
The default css classes can be overriden in ConsoleLogHTML.DEFAULTS:
ConsoleLogHTML.DEFAULTS.error = "some-error-css-class"; // Will be applied to console.error()
ConsoleLogHTML.DEFAULTS.log = "another-override"; // Will be applied to console.log()
The connect method has the following signature:
function connect(target, options, includeTimestamp, logToConsole){}
target has already been covered - it's the <ul> elementoptions allows you to override the css classes in ConsoleLogHTML.DEFAULTS for the duration of the connect, i.e. it
would not save the values. For example, if you wanted to override the log and warn CSS classes you could pass the object{
"warn": "my-warn-css-class",
"log": "my-log-css-class"
}
includeTimestamp - when set to true (the default value), a timestamp will be prepended to each message as it
appears in the <ul>. The timestamp's format depends on the user as it is created via(new Date()).toLocaleTimeString()
logToConsole - when set to true (the default value), appear both in the console and the <ul>; when set
to false, they appear only in the <ul>.appendAtBottom - when set to true (default=false), log messages will be appended at the end of the <ul>-list.More information:
FAQs
Copies/redirects console output to HTML
We found that console-log-html demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.