Skip to content

Instantly share code, notes, and snippets.

@brandonsueur brandonsueur/log.js
Last active May 23, 2018

Embed
What would you like to do?
πŸ‘¨β€πŸ’»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
You can’t perform that action at this time.