-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathLogger.js
67 lines (60 loc) · 1.72 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
const countlyNamespace = "[CountlyReactNative] ";
let canLog = false;
/**
* Initialize logger
* @param {Boolean} debugMode
*/
function initialize(debugMode) {
canLog = debugMode && console !== undefined;
i("[Logger] initializing the module");
}
/**
* Error - this is for things that need immediate attention because SDK won’t work.
* @param {String} message
*/
function e(message) {
if (canLog) {
console.error(countlyNamespace + message);
}
}
/**
* Warning - this is something that is potentially a issue. Maybe a deprecated usage of something,
* maybe consent is enabled but consent is not given.
* @param {String} message
*/
function w(message) {
if (canLog) {
console.warn(countlyNamespace + message);
}
}
/**
* Info - All publicly exposed functions should log a call at this level to indicate that they were called.
* @param {String} message
*/
function i(message) {
if (canLog) {
console.info(countlyNamespace + message);
}
}
/**
* Debug - this should contain logs from the internal workings of the SDK and it's important calls.
* This should include things like the SDK configuration options, success or fail of the current network request,
* "request queue is full" and the oldest request get's dropped, etc.
* @param {String} message
*/
function d(message) {
if (canLog) {
console.debug(countlyNamespace + message);
}
}
/**
* Verbose - this should give an even deeper look into the SDK's inner working
* and should contain things that are more noisy and happen often.
* @param {String} message
*/
function v(message) {
if (canLog) {
console.log(`[VERBOSE]${countlyNamespace}${message}`);
}
}
export { initialize, e, w, i, d, v };