-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlogify.js
43 lines (35 loc) · 967 Bytes
/
logify.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
39
40
41
42
/**
* Simple custom loggin' class
* @param {integer} fontSize
* @author m3dric
*/
// Font
const DEFAULT_FONT_SIZE = 12;
// Colors
const INFO_COLOR = '#81C784';
const WARNING_COLOR = '#FFB74D';
const ERROR_COLOR = '#E57373';
function Logify(fontSize) {
// Object properties
this.fontSize = fontSize || DEFAULT_FONT_SIZE;
}
Logify.prototype.info = function(message) {
log('%c%s',
'color: #FFF; background: ' + INFO_COLOR + '; font-size: ' + DEFAULT_FONT_SIZE + 'px',
message);
}
Logify.prototype.warning = function(message) {
log('%c%s',
'color: #FFF; background: ' + WARNING_COLOR + '; font-size: ' + DEFAULT_FONT_SIZE + 'px',
message);
}
Logify.prototype.error = function(message) {
log('%c%s',
'color: #FFF; background: ' + ERROR_COLOR + '; font-size: ' + DEFAULT_FONT_SIZE + 'px',
message);
}
// Private
//
var log = function() {
console.log.apply(console, arguments);
}