Skip to content

Instantly share code, notes, and snippets.

@brandonsueur
Last active May 23, 2018 16:34
Show Gist options
  • Save brandonsueur/11943eb7586fd560968ec5fa87f799fb to your computer and use it in GitHub Desktop.
Save brandonsueur/11943eb7586fd560968ec5fa87f799fb to your computer and use it in GitHub Desktop.
πŸ‘¨β€πŸ’»Custom console.log()
String.prototype.duplicate = (num) = {
let str = "";
for(let i=0; i<num; i++){
str += this;
}
return str;
};
const log = (e, title=null) => {
let colors = [
'#914285', '#282a6a', '#e89344', '#cafc04', '#e0a41b', '#d6cb1b', '#c36b63', '#f6f287', '#e86d05', '#f7e943', '#c49333', '#f1f050', '#c8a35a', '#f5f03a', '#a67b2d', '#d3cc3a', '#fa9309', '#fdc92b', '#cb450e', '#d6e136', '#b86b14', '#7fb27f', '#b2d1b2', '#006600', '#f8f8f8', '#d64d4d', '#000000', '#ae0001', '#61bb46', '#ddc524', '#ffd632', '#1c1532', '#392a65', '#e3b88b', '#fee3dd', '#6e4d58', '#f7e7d1', '#f2c390', '#078446', '#048364', '#028373', '#006282'
];
if(e != null){
if(title != null){
console.log(
'%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ' +
'%c ' + title+
' %c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ',+
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + 'black',
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors)
);
}
else{
console.log(
'%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ' +
'%c/[-~^~-]\\' +
'%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ',+
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + 'black',
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors)
);
}
console.log(e);
console.log(
'%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ' +
'%c ᚏ end ᚏ' +
'%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ' + '%c ᚏ',+
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + 'black',
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors),
'color:' + _.sample(colors)
);
}else{
console.log(
'['+ '%cx' + '%c] '+ '%cErreur!'+ '%c Votre function '+ '%clog()' + '%c est vide.',
'color: red', 'color: black', 'color: red', 'color: black', 'color: #914285', 'color: black'
);
}
}
const hello = (name = 'Brandon') => {
console.log('Bonjour, comment vas-tu ' + name + ' ?');
}
log('Salut', 'mon texte salut');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment