-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
Log.js
38 lines (34 loc) · 1.13 KB
/
Log.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
import Logger from 'expensify-common/lib/Logger';
import * as API from './API';
import CONFIG from '../CONFIG';
import getPlatform from './getPlatform';
import {version} from '../../package.json';
import NetworkConnection from './NetworkConnection';
/**
* Network interface for logger.
*
* @param {Object} params
* @param {Object} params.parameters
* @param {String} params.message
*/
function serverLoggingCallback(params) {
const requestParams = {
message: params.message,
parameters: JSON.stringify(params.parameters || {}),
expensifyCashAppVersion: `expensifyCash[${getPlatform()}]${version}`,
};
API.Log(requestParams);
}
// Note: We are importing Logger from expensify-common because it is
// used by other platforms. The server and client logging
// callback methods are passed in here so we can decouple
// the logging library from the logging methods.
const Log = new Logger({
serverLoggingCallback,
clientLoggingCallback: (message) => {
console.debug(message);
},
isDebug: !CONFIG.IS_IN_PRODUCTION,
});
NetworkConnection.registerLogInfoCallback(Log.info);
export default Log;