"Fossies" - the Fresh Open Source Software Archive

Member "jitsi-meet-7328/react/features/base/logging/functions.ts" (8 Jun 2023, 1363 Bytes) of package /linux/misc/jitsi-meet-7328.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 // @ts-expect-error
    2 import Logger, { getLogger as _getLogger } from '@jitsi/logger';
    3 import _ from 'lodash';
    4 
    5 import LogTransport from './LogTransport';
    6 
    7 /**
    8  * Options for building the logger. We disable the callee info on RN because it's
    9  * almost always empty anyway.
   10  */
   11 const DEFAULT_OPTS = {};
   12 const DEFAULT_RN_OPTS = { disableCallerInfo: true };
   13 
   14 /**
   15  * Gets a logger for the given id.
   16  *
   17  * @param {string} id - Name for the logger.
   18  * @returns {Object} - The logger object.
   19  */
   20 export function getLogger(id: string) {
   21     const opts = navigator.product === 'ReactNative' ? DEFAULT_RN_OPTS : DEFAULT_OPTS;
   22 
   23     return _getLogger(id, undefined, opts);
   24 }
   25 
   26 /**
   27  * Initializes native logging. This operations must be done as early as possible.
   28  */
   29 export const _initLogging = _.once(() => {
   30     if (navigator.product !== 'ReactNative') {
   31         return;
   32     }
   33 
   34     // Lazy load it to avoid cycles in early web bootstrap code.
   35     // eslint-disable-next-line @typescript-eslint/no-var-requires
   36     const { default: JitsiMeetJS } = require('../lib-jitsi-meet/_');
   37 
   38     Logger.setGlobalOptions(DEFAULT_RN_OPTS);
   39     JitsiMeetJS.setGlobalLogOptions(DEFAULT_RN_OPTS);
   40     Logger.removeGlobalTransport(console);
   41     JitsiMeetJS.removeGlobalLogTransport(console);
   42     Logger.addGlobalTransport(LogTransport);
   43     JitsiMeetJS.addGlobalLogTransport(LogTransport);
   44 });