-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimpleLogger.js
More file actions
37 lines (35 loc) · 838 Bytes
/
simpleLogger.js
File metadata and controls
37 lines (35 loc) · 838 Bytes
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
/**
* Created by JetBrains WebStorm.
* User: mru
* Date: 04/01/12
* Time: 19:46
* To change this template use File | Settings | File Templates.
*/
//Singleton
exports.log = (function simpleLogger() {
"use strict";
var utils = require('util'),
_prefix = '',
_enabled = true,
_level = 'W',
_set_prefix = function (str) {
_prefix = str;
},
_set_enabled = function (flag) {
_enabled = flag;
},
_set_level = function (level) {
_level = level;
},
_log = function (str) {
if (_enabled) {
utils.log(_prefix + '::' + str);
}
};
return {
log:_log,
set_prefix:_set_prefix,
set_level:_set_level,
set_enabled:_set_enabled
};
})();