Skip to content

Instantly share code, notes, and snippets.

@sulco
Created December 10, 2018 19:11
Show Gist options
  • Save sulco/e635a7511d5ff17d44fe9bb2ab8b3cc6 to your computer and use it in GitHub Desktop.
Save sulco/e635a7511d5ff17d44fe9bb2ab8b3cc6 to your computer and use it in GitHub Desktop.
A clown formatter
window.devtoolsFormatters = [{
header: function(obj){
if (!obj.__clown) {
return null;
}
delete obj.__clown;
const style = `
color: red;
border: dotted 2px gray;
border-radius: 4px;
padding: 5px;
`
const content = `🤡 ${JSON.stringify(obj, null, 2)}`;
try {
return ['div', {style}, content]
} catch (err) { // for circular structures
return null; // use the default formatter
}
},
hasBody: function(){
return false;
}
}]
console.clown = function (obj) {
console.log({...obj, __clown: true});
}
console.log({message: 'hello!'}); // normal log
console.clown({message: 'hello!'}); // a silly log
Copy link

ghost commented Apr 8, 2019

nice! I got it and shared it to my workmate, thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment