-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogger.js
executable file
·80 lines (71 loc) · 1.14 KB
/
logger.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/**
* Output log messages
*/
var Logger = function() {
/**
* DEBUG constant
* @var int
*/
this.DEBUG = 0;
/**
* WARNING constant
* @var int
*/
this.WARNING = 1;
/**
* ERROR constant
* @var int
*/
this.ERROR = 2;
/**
* MESSAGE constant
* @var int
*/
this.MESSAGE = 3;
/**
* Message
* @param string message
*/
this.message = function( string ) {
this.log( this.MESSAGE, string );
};
/**
* Error
* @param string message
*/
this.error = function( string ) {
this.log( this.ERROR, string );
};
/**
* Warn
* @param string message
*/
this.warn = function( string ) {
this.log( this.WARNING, string );
};
/**
* Debug
* @param string message
*/
this.debug = function( string ) {
this.log( this.DEBUG, string );
};
/**
* Log a message
* @param string level
* @param string message
*/
this.log = function( level, message ) {
var levels = {
0 : "DEBUG",
1 : "WARNING",
2 : "ERROR",
3 : "MESSAGE"
},
d = new Date();
if ( level < Config.log_level ) {
return;
}
console.log( "[ " + d.toDateString() + " " + levels[ level ] + " ]: " + message );
};
};