2019-08-21 14:50:00 +00:00
|
|
|
// @flow
|
|
|
|
|
2019-08-28 10:31:38 +00:00
|
|
|
import _ from 'lodash';
|
|
|
|
import Logger, { getLogger as _getLogger } from 'jitsi-meet-logger';
|
|
|
|
|
|
|
|
import LogTransport from './LogTransport';
|
2019-08-21 14:50:00 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Options for building the logger. We disable the callee info on RN because it's
|
|
|
|
* almost always empty anyway.
|
|
|
|
*/
|
|
|
|
const DEFAULT_OPTS = {};
|
|
|
|
const DEFAULT_RN_OPTS = { disableCallerInfo: true };
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets a logger for the given id.
|
|
|
|
*
|
|
|
|
* @param {string} id - Name for the logger.
|
|
|
|
* @returns {Object} - The logger object.
|
|
|
|
*/
|
|
|
|
export function getLogger(id: string) {
|
|
|
|
const opts = navigator.product === 'ReactNative' ? DEFAULT_RN_OPTS : DEFAULT_OPTS;
|
|
|
|
|
|
|
|
return _getLogger(id, undefined, opts);
|
|
|
|
}
|
2019-08-28 10:31:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes native logging. This operations must be done as early as possible.
|
|
|
|
*/
|
|
|
|
export const _initLogging = _.once(() => {
|
|
|
|
if (navigator.product !== 'ReactNative') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Lazy load it to avoid cycles in early web bootstrap code.
|
2019-09-13 13:03:40 +00:00
|
|
|
const { default: JitsiMeetJS } = require('../lib-jitsi-meet/_');
|
2019-08-28 10:31:38 +00:00
|
|
|
|
|
|
|
Logger.setGlobalOptions(DEFAULT_RN_OPTS);
|
|
|
|
JitsiMeetJS.setGlobalLogOptions(DEFAULT_RN_OPTS);
|
|
|
|
Logger.removeGlobalTransport(console);
|
|
|
|
JitsiMeetJS.removeGlobalLogTransport(console);
|
|
|
|
Logger.addGlobalTransport(LogTransport);
|
|
|
|
JitsiMeetJS.addGlobalLogTransport(LogTransport);
|
|
|
|
});
|