Skip to content

Instantly share code, notes, and snippets.

@datchley
Created April 16, 2014 16:53
Show Gist options
  • Select an option

  • Save datchley/10906325 to your computer and use it in GitHub Desktop.

Select an option

Save datchley/10906325 to your computer and use it in GitHub Desktop.
Styled, timestamped console log messages for chrome's console API.
function _debug() {
var tm = "%c[" + (new Date()).toTimeString().split(/\s+/)[0] + "]",
pre = "%c debug ",
args = [].slice.call(arguments, 0),
// styles for: timestamp, prefix, message
styles = ["color: #4682b4", "color: #fff; background-color: #cd5c5c;", "color: #2f4f4f"],
msg = tm + pre + "%c " + args.shift();
console.log.apply(console, [msg].concat(styles, args));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment