Skip to main content
deleted 89 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
  • All calls to console.log() (info(), warn(), error(), table(), and clear()) are passed along to the actual console
  • Loosely imitates Chrome's output (colors and styles excluded)
  • Handles circular references via lazy-expansion.
  • Works by injecting elements into the page... so, it obviously pollutes the DOM.
  • The number of entries is limited to 50. Older entries will be removed to make room for newer entries.
  • Logs unhandled errors.
  • Handles circular references. You could log window; though, I wouldn't recommend it.
/* config stuff... ignore this line */ console.config({ maximize: true, timeStamps: false });

// sample data
const values = [
  1e100, 
  "a",
  true, 
  new Date(), 
  x => 1, 
  /(?:)/ig, 
  undefined, 
  null,
  document.querySelector("button")
];

// add a circular reference
values.push(values);

// log whole array with circular reference
console.log("array with circular reference: %o", values);

// log each value individually
values.forEach((v, i) => console.log("%i: %o", i, v));

// table output
console.table([
  { Name: "Zoe", Age: 20 },
  { Name: "Xander", Age: 21 },
  { Name: "Cthulhu", Age: Infinity },
]);

// throw a test error
throw new Error("test!");
<!-- console visualization; see http://meta.stackexchange.com/a/242491 -->
<script src="https://gh-canon.github.io/stack-snippet-console/console.min.js"></script>
<button>click me</button>
  • All calls to console.log() (info(), warn(), error(), table(), and clear()) are passed along to the actual console
  • Loosely imitates Chrome's output (colors and styles excluded)
  • Handles circular references via lazy-expansion.
  • Works by injecting elements into the page... so, it obviously pollutes the DOM.
  • The number of entries is limited to 50. Older entries will be removed to make room for newer entries.
  • Logs unhandled errors.
  • Handles circular references. You could log window; though, I wouldn't recommend it.
/* config stuff... ignore this line */ console.config({ maximize:true });

// sample data
const values = [
  1e100, 
  "a",
  true, 
  new Date(), 
  x => 1, 
  /(?:)/ig, 
  undefined, 
  null,
  document.querySelector("button")
];

// add a circular reference
values.push(values);

// log whole array with circular reference
console.log("array with circular reference: %o", values);

// log each value individually
values.forEach((v, i) => console.log("%i: %o", i, v));

// table output
console.table([
  { Name: "Zoe", Age: 20 },
  { Name: "Xander", Age: 21 },
  { Name: "Cthulhu", Age: Infinity },
]);

// throw a test error
throw new Error("test!");
<!-- console visualization; see http://meta.stackexchange.com/a/242491 -->
<script src="https://gh-canon.github.io/stack-snippet-console/console.min.js"></script>
<button>click me</button>
  • All calls to console.log() (info(), warn(), error(), table(), and clear()) are passed along to the actual console
  • Loosely imitates Chrome's output (colors and styles excluded)
  • Handles circular references via lazy-expansion.
  • Works by injecting elements into the page... so, it obviously pollutes the DOM.
  • The number of entries is limited to 50. Older entries will be removed to make room for newer entries.
  • Logs unhandled errors.
/* config stuff... ignore this line */ console.config({ maximize: true, timeStamps: false });

// sample data
const values = [
  1e100, 
  "a",
  true, 
  new Date(), 
  x => 1, 
  /(?:)/ig, 
  undefined, 
  null,
  document.querySelector("button")
];

// add a circular reference
values.push(values);

// log whole array with circular reference
console.log("array with circular reference: %o", values);

// log each value individually
values.forEach((v, i) => console.log("%i: %o", i, v));

// table output
console.table([
  { Name: "Zoe", Age: 20 },
  { Name: "Xander", Age: 21 },
  { Name: "Cthulhu", Age: Infinity },
]);

// throw a test error
throw new Error("test!");
<!-- console visualization; see http://meta.stackexchange.com/a/242491 -->
<script src="https://gh-canon.github.io/stack-snippet-console/console.min.js"></script>
<button>click me</button>
added 338 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
  • All calls to console.log() (info(), warn(), error(), table(), and clear()) are passed along to the actual console
  • Loosely imitates Chrome's output (colors and styles excluded)
  • Handles circular references via lazy-expansion.
  • Works by injecting elements into the page... so, it obviously pollutes the DOM.
  • The number of entries is limited to 50. Older entries will be removed to make room for newer entries.
  • Logs unhandled errors.
  • Handles circular references. You could log window; though, I wouldn't recommend it.
/* config stuff... ignore this line */ console.config({ maximize:true });

// sample valuesdata
varconst values = [1e100[
  1e100, 
  "a",
  true, 
  new Date(), 
  x => 1, 
  /(?:)/ig, 
  undefined, null];
  null,
  document.querySelector("button")
];

// add a circular reference
values.push(values);

// log whole array with circular reference
console.log("array with circular reference: %o", values);

// log each value individually
values.forEach((v, i) => console.log("%i: %o", i, v));

// sample clicktable handleroutput
document.querySelector("button")console.addEventListenertable("click",[
 function(e) { Name: "Zoe", Age: 20 },
  console.log("clicked{ Name: %o""Xander", this);Age: 21 },
  { Name: "Cthulhu", Age: Infinity },
]);

// throw a test error
throw new Error("test!");
<!-- console visualization; see http://meta.stackexchange.com/a/242491 -->
<script src="https://gh-canon.github.io/stack-snippet-console/console.min.js"></script>
<button>click me</button>
 

 
  • All calls to console.log() (info(), warn(), error(), and clear()) are passed along to the actual console
  • Loosely imitates Chrome's output (colors and styles excluded)
  • Handles circular references via lazy-expansion.
  • Works by injecting elements into the page... so, it obviously pollutes the DOM.
  • The number of entries is limited to 50. Older entries will be removed to make room for newer entries.
  • Logs unhandled errors.
  • Handles circular references. You could log window; though, I wouldn't recommend it.
// sample values
var values = [1e100, "a", true, new Date(), x => 1, /(?:)/ig, undefined, null];

// add a circular reference
values.push(values);

// log whole array with circular reference
console.log("array with circular reference: %o", values);

// log each value individually
values.forEach((v, i) => console.log("%i: %o", i, v));

// sample click handler
document.querySelector("button").addEventListener("click", function(e) {
  console.log("clicked: %o", this);
});

// throw a test error
throw new Error("test!");
<!-- console visualization; see http://meta.stackexchange.com/a/242491 -->
<script src="https://gh-canon.github.io/stack-snippet-console/console.min.js"></script>
<button>click me</button>

 
  • All calls to console.log() (info(), warn(), error(), table(), and clear()) are passed along to the actual console
  • Loosely imitates Chrome's output (colors and styles excluded)
  • Handles circular references via lazy-expansion.
  • Works by injecting elements into the page... so, it obviously pollutes the DOM.
  • The number of entries is limited to 50. Older entries will be removed to make room for newer entries.
  • Logs unhandled errors.
  • Handles circular references. You could log window; though, I wouldn't recommend it.
/* config stuff... ignore this line */ console.config({ maximize:true });

// sample data
const values = [
  1e100, 
  "a",
  true, 
  new Date(), 
  x => 1, 
  /(?:)/ig, 
  undefined, 
  null,
  document.querySelector("button")
];

// add a circular reference
values.push(values);

// log whole array with circular reference
console.log("array with circular reference: %o", values);

// log each value individually
values.forEach((v, i) => console.log("%i: %o", i, v));

// table output
console.table([
  { Name: "Zoe", Age: 20 },
  { Name: "Xander", Age: 21 },
  { Name: "Cthulhu", Age: Infinity },
]);

// throw a test error
throw new Error("test!");
<!-- console visualization; see http://meta.stackexchange.com/a/242491 -->
<script src="https://gh-canon.github.io/stack-snippet-console/console.min.js"></script>
<button>click me</button>
 

deleted 96 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
  • All calls to console.log() (info(), warn(), error(), and clear()) are passed along to the actual console
  • Loosely imitates Chrome's output (colors and styles excluded)
  • Objects are printed using a variation of JSON.stringify() (including functions, regex, undefined, etc) with custom handling for HTMLElementHandles circular references via lazy-expansion.
  • Works by injecting elements into the page... so, it obviously pollutes the DOM.
  • The number of entries is limited to 50. Older entries will be removed to make room for newer entries.
  • Logs unhandled errors.
  • Handles circular references. You could log window; though, I wouldn't recommend it.
  • All calls to console.log() (info(), warn(), error(), and clear()) are passed along to the actual console
  • Loosely imitates Chrome's output (colors and styles excluded)
  • Objects are printed using a variation of JSON.stringify() (including functions, regex, undefined, etc) with custom handling for HTMLElement
  • Works by injecting elements into the page... so, it obviously pollutes the DOM.
  • The number of entries is limited to 50. Older entries will be removed to make room for newer entries.
  • Logs unhandled errors.
  • Handles circular references. You could log window; though, I wouldn't recommend it.
  • All calls to console.log() (info(), warn(), error(), and clear()) are passed along to the actual console
  • Loosely imitates Chrome's output (colors and styles excluded)
  • Handles circular references via lazy-expansion.
  • Works by injecting elements into the page... so, it obviously pollutes the DOM.
  • The number of entries is limited to 50. Older entries will be removed to make room for newer entries.
  • Logs unhandled errors.
  • Handles circular references. You could log window; though, I wouldn't recommend it.
Updated demo to avoid confusion with lazy object expansion.
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
replaced http://meta.stackoverflow.com/ with https://meta.stackoverflow.com/
Source Link
Loading
Use HTTPS links since this solution does not work on the HTTPS version of the page otherwise; nicer (now HTML-based) list at the bottom of page
Source Link
Loading
Bounty Ended with 500 reputation awarded by Josh Crozier
added 34 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
added 72 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
added 188 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
added 94 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
deleted 2259 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
added 32 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
added 390 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
added 36 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
deleted 47 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
added 11 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
added 125 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
Bounty Ended with 500 reputation awarded by T.J. Crowder
deleted 23 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
deleted 285 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
added 177 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
added 177 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
added 498 characters in body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading
edited body
Source Link
canon
  • 2.2k
  • 1
  • 24
  • 33
Loading