feat(loggin) forward logs to external api
This commit is contained in:
parent
d5dae945a8
commit
e2731ce73e
|
@ -510,6 +510,9 @@ var config = {
|
|||
// ],
|
||||
},
|
||||
|
||||
// Logs that should go be passed through the 'log' event if a handler is defined for it
|
||||
// apiLogLevels: ['warn', 'log', 'error', 'info', 'debug'],
|
||||
|
||||
// Information about the jitsi-meet instance we are connecting to, including
|
||||
// the user region as seen by the server.
|
||||
deploymentInfo: {
|
||||
|
|
|
@ -696,6 +696,21 @@ class API {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify external application (if API is enabled) that the an error has been logged.
|
||||
*
|
||||
* @param {string} logLevel - The message log level.
|
||||
* @param {Array} args - Array of strings composing the log message.
|
||||
* @returns {void}
|
||||
*/
|
||||
notifyLog(logLevel: string, args: Array<string>) {
|
||||
this._sendEvent({
|
||||
name: 'log',
|
||||
logLevel,
|
||||
args
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify external application (if API is enabled) that the conference has
|
||||
* been joined.
|
||||
|
|
|
@ -68,6 +68,7 @@ const events = {
|
|||
'feedback-prompt-displayed': 'feedbackPromptDisplayed',
|
||||
'filmstrip-display-changed': 'filmstripDisplayChanged',
|
||||
'incoming-message': 'incomingMessage',
|
||||
'log': 'log',
|
||||
'mic-error': 'micError',
|
||||
'outgoing-message': 'outgoingMessage',
|
||||
'participant-joined': 'participantJoined',
|
||||
|
@ -543,6 +544,13 @@ export default class JitsiMeetExternalAPI extends EventEmitter {
|
|||
* the event and value - the listener.
|
||||
* Currently we support the following
|
||||
* events:
|
||||
* {@code log} - receives event notifications whenever information has
|
||||
* been logged and has a log level specified within {@code config.apiLogLevels}.
|
||||
* The listener will receive object with the following structure:
|
||||
* {{
|
||||
* logLevel: the message log level
|
||||
* arguments: an array of strings that compose the actual log message
|
||||
* }}
|
||||
* {@code incomingMessage} - receives event notifications about incoming
|
||||
* messages. The listener will receive object with the following structure:
|
||||
* {{
|
||||
|
|
|
@ -17,6 +17,7 @@ export default [
|
|||
'audioLevelsInterval',
|
||||
'autoRecord',
|
||||
'autoRecordToken',
|
||||
'apiLogLevels',
|
||||
'avgRtpStatsN',
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
// @flow
|
||||
|
||||
declare var APP: Object;
|
||||
|
||||
/**
|
||||
* Constructs a log transport object for use with external API.
|
||||
*
|
||||
* @param {Array} levels - The log levels forwarded to the external API.
|
||||
|
||||
* @returns {Object} - The transport object.
|
||||
*/
|
||||
function buildTransport(levels: Array<string>) {
|
||||
return levels.reduce((logger, level) => {
|
||||
logger[level] = (...args) => {
|
||||
APP.API.notifyLog(level, args);
|
||||
};
|
||||
|
||||
return logger;
|
||||
}, {});
|
||||
}
|
||||
|
||||
export default buildTransport;
|
|
@ -11,6 +11,7 @@ import JitsiMeetJS, {
|
|||
import { MiddlewareRegistry } from '../redux';
|
||||
import { isTestModeEnabled } from '../testing';
|
||||
|
||||
import buildExternalApiLogTransport from './ExternalApiLogTransport';
|
||||
import JitsiMeetInMemoryLogStorage from './JitsiMeetInMemoryLogStorage';
|
||||
import JitsiMeetLogStorage from './JitsiMeetLogStorage';
|
||||
import { SET_LOGGING_CONFIG } from './actionTypes';
|
||||
|
@ -141,6 +142,15 @@ function _initLogging({ dispatch, getState }, loggingConfig, isTestingEnabled) {
|
|||
const _logCollector
|
||||
= new Logger.LogCollector(new JitsiMeetLogStorage(getState));
|
||||
|
||||
const { apiLogLevels } = getState()['features/base/config'];
|
||||
|
||||
if (apiLogLevels && Array.isArray(apiLogLevels) && typeof APP === 'object') {
|
||||
const transport = buildExternalApiLogTransport(apiLogLevels);
|
||||
|
||||
Logger.addGlobalTransport(transport);
|
||||
JitsiMeetJS.addGlobalLogTransport(transport);
|
||||
}
|
||||
|
||||
Logger.addGlobalTransport(_logCollector);
|
||||
JitsiMeetJS.addGlobalLogTransport(_logCollector);
|
||||
dispatch(setLogCollector(_logCollector));
|
||||
|
|
Loading…
Reference in New Issue