snapshot of https://github.com/jitsi/jitsi-meet.git @ fd1749dd28f4138aa80234fc7f311b19aaffa0e7 (2026-09-15)
This commit is contained in:
44
react/features/base/logging/functions.ts
Normal file
44
react/features/base/logging/functions.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
// @ts-expect-error
|
||||
import Logger, { getLogger as _getLogger } from '@jitsi/logger';
|
||||
import { once } from 'lodash-es';
|
||||
|
||||
import LogTransport from './LogTransport';
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const { default: JitsiMeetJS } = require('../lib-jitsi-meet/_');
|
||||
|
||||
Logger.setGlobalOptions(DEFAULT_RN_OPTS);
|
||||
JitsiMeetJS.setGlobalLogOptions(DEFAULT_RN_OPTS);
|
||||
Logger.removeGlobalTransport(console);
|
||||
JitsiMeetJS.removeGlobalLogTransport(console);
|
||||
Logger.addGlobalTransport(LogTransport);
|
||||
JitsiMeetJS.addGlobalLogTransport(LogTransport);
|
||||
});
|
||||
Reference in New Issue
Block a user