Selaa lähdekoodia

feat(loggin) forward logs to external api

j8
Tudor-Ovidiu Avram 5 vuotta sitten
vanhempi
commit
e2731ce73e

+ 3
- 0
config.js Näytä tiedosto

510
         // ],
510
         // ],
511
     },
511
     },
512
 
512
 
513
+    // Logs that should go be passed through the 'log' event if a handler is defined for it
514
+    // apiLogLevels: ['warn', 'log', 'error', 'info', 'debug'],
515
+
513
     // Information about the jitsi-meet instance we are connecting to, including
516
     // Information about the jitsi-meet instance we are connecting to, including
514
     // the user region as seen by the server.
517
     // the user region as seen by the server.
515
     deploymentInfo: {
518
     deploymentInfo: {

+ 15
- 0
modules/API/API.js Näytä tiedosto

696
         });
696
         });
697
     }
697
     }
698
 
698
 
699
+    /**
700
+     * Notify external application (if API is enabled) that the an error has been logged.
701
+     *
702
+     * @param {string} logLevel - The message log level.
703
+     * @param {Array} args - Array of strings composing the log message.
704
+     * @returns {void}
705
+     */
706
+    notifyLog(logLevel: string, args: Array<string>) {
707
+        this._sendEvent({
708
+            name: 'log',
709
+            logLevel,
710
+            args
711
+        });
712
+    }
713
+
699
     /**
714
     /**
700
      * Notify external application (if API is enabled) that the conference has
715
      * Notify external application (if API is enabled) that the conference has
701
      * been joined.
716
      * been joined.

+ 8
- 0
modules/API/external/external_api.js Näytä tiedosto

68
     'feedback-prompt-displayed': 'feedbackPromptDisplayed',
68
     'feedback-prompt-displayed': 'feedbackPromptDisplayed',
69
     'filmstrip-display-changed': 'filmstripDisplayChanged',
69
     'filmstrip-display-changed': 'filmstripDisplayChanged',
70
     'incoming-message': 'incomingMessage',
70
     'incoming-message': 'incomingMessage',
71
+    'log': 'log',
71
     'mic-error': 'micError',
72
     'mic-error': 'micError',
72
     'outgoing-message': 'outgoingMessage',
73
     'outgoing-message': 'outgoingMessage',
73
     'participant-joined': 'participantJoined',
74
     'participant-joined': 'participantJoined',
543
      * the event and value - the listener.
544
      * the event and value - the listener.
544
      * Currently we support the following
545
      * Currently we support the following
545
      * events:
546
      * events:
547
+     * {@code log} - receives event notifications whenever information has
548
+     * been logged and has a log level specified within {@code config.apiLogLevels}.
549
+     * The listener will receive object with the following structure:
550
+     * {{
551
+     * logLevel: the message log level
552
+     * arguments: an array of strings that compose the actual log message
553
+     * }}
546
      * {@code incomingMessage} - receives event notifications about incoming
554
      * {@code incomingMessage} - receives event notifications about incoming
547
      * messages. The listener will receive object with the following structure:
555
      * messages. The listener will receive object with the following structure:
548
      * {{
556
      * {{

+ 1
- 0
react/features/base/config/configWhitelist.js Näytä tiedosto

17
     'audioLevelsInterval',
17
     'audioLevelsInterval',
18
     'autoRecord',
18
     'autoRecord',
19
     'autoRecordToken',
19
     'autoRecordToken',
20
+    'apiLogLevels',
20
     'avgRtpStatsN',
21
     'avgRtpStatsN',
21
 
22
 
22
     /**
23
     /**

+ 22
- 0
react/features/base/logging/ExternalApiLogTransport.js Näytä tiedosto

1
+// @flow
2
+
3
+declare var APP: Object;
4
+
5
+/**
6
+ * Constructs a log transport object for use with external API.
7
+ *
8
+ * @param {Array} levels - The log levels forwarded to the external API.
9
+
10
+ * @returns {Object} - The transport object.
11
+ */
12
+function buildTransport(levels: Array<string>) {
13
+    return levels.reduce((logger, level) => {
14
+        logger[level] = (...args) => {
15
+            APP.API.notifyLog(level, args);
16
+        };
17
+
18
+        return logger;
19
+    }, {});
20
+}
21
+
22
+export default buildTransport;

+ 10
- 0
react/features/base/logging/middleware.js Näytä tiedosto

11
 import { MiddlewareRegistry } from '../redux';
11
 import { MiddlewareRegistry } from '../redux';
12
 import { isTestModeEnabled } from '../testing';
12
 import { isTestModeEnabled } from '../testing';
13
 
13
 
14
+import buildExternalApiLogTransport from './ExternalApiLogTransport';
14
 import JitsiMeetInMemoryLogStorage from './JitsiMeetInMemoryLogStorage';
15
 import JitsiMeetInMemoryLogStorage from './JitsiMeetInMemoryLogStorage';
15
 import JitsiMeetLogStorage from './JitsiMeetLogStorage';
16
 import JitsiMeetLogStorage from './JitsiMeetLogStorage';
16
 import { SET_LOGGING_CONFIG } from './actionTypes';
17
 import { SET_LOGGING_CONFIG } from './actionTypes';
141
         const _logCollector
142
         const _logCollector
142
             = new Logger.LogCollector(new JitsiMeetLogStorage(getState));
143
             = new Logger.LogCollector(new JitsiMeetLogStorage(getState));
143
 
144
 
145
+        const { apiLogLevels } = getState()['features/base/config'];
146
+
147
+        if (apiLogLevels && Array.isArray(apiLogLevels) && typeof APP === 'object') {
148
+            const transport = buildExternalApiLogTransport(apiLogLevels);
149
+
150
+            Logger.addGlobalTransport(transport);
151
+            JitsiMeetJS.addGlobalLogTransport(transport);
152
+        }
153
+
144
         Logger.addGlobalTransport(_logCollector);
154
         Logger.addGlobalTransport(_logCollector);
145
         JitsiMeetJS.addGlobalLogTransport(_logCollector);
155
         JitsiMeetJS.addGlobalLogTransport(_logCollector);
146
         dispatch(setLogCollector(_logCollector));
156
         dispatch(setLogCollector(_logCollector));

Loading…
Peruuta
Tallenna