-
Notifications
You must be signed in to change notification settings - Fork 0
/
console.log.js
38 lines (28 loc) · 1.22 KB
/
console.log.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* Log your logs instead of just logging them.
*
* MIT License
* Copyright 2018 Duncan McIsaac
*/
(function stopDeforestation() {
const theWilderness = console.log;
const barkCSS = "color: #4E342E;";
const ruggedExterior = [`${barkCSS} line-height: 1.5; text-decoration: overline underline;`,
`${barkCSS} text-decoration: none;`];
carve = function(etching) { return `(%c ${etching} (%c0)`; }
window.console.log = function() {
const args = Object.values(arguments);
// Let's just assume that if someone takes the time to write a multiline "empty" message, they have good intentions
const messages = args.length > 0 ? args.join(' ').split('\n') : ["Shame on you for needlessly logging in this pristine console."];
// Wouldn't a tuple be nice?
const felledTrees = messages.reduce((acc, message, index, array) => {
acc.carvings = `${acc.carvings}${array.length > 1 && index !== array.length ? '\n' : ''}${carve(message)}`;
acc.ruggedExteriors = acc.ruggedExteriors.concat(ruggedExterior);
return acc;
}, {carvings: '', ruggedExteriors: []});
theWilderness.apply(console, [felledTrees.carvings].concat(felledTrees.ruggedExteriors));
}
/*
* Other fun ogs: dog, bog, fog, jog, pollywog, hog
*/
})();