-
Notifications
You must be signed in to change notification settings - Fork 136
/
Log.jsx
39 lines (35 loc) · 967 Bytes
/
Log.jsx
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
/* eslint-disable no-console */
import API from './API';
import Network from './Network';
import Logger from './Logger';
import * as Utils from './utils';
/**
* Network interface for logger.
*
* @param {Logger} logger
* @param {Object} params
* @param {Object} params.parameters
* @param {String} params.message
* @return {Promise}
*/
function serverLoggingCallback(logger, params) {
return API(Network('/api/')).logToServer(params);
}
/**
* Local log messages for client logging.
*
* @param {String} message
*/
function clientLoggingCallback(message) {
if (Utils.isWindowAvailable() && typeof window.g_printableReport !== 'undefined' && window.g_printableReport === true) {
return;
}
if (window.console && Utils.isFunction(console.log)) {
console.log(message);
}
}
export default new Logger({
serverLoggingCallback,
clientLoggingCallback,
isDebug: Utils.isWindowAvailable() ? window.DEBUG : false,
});