The Web SDK logs as posted on the browser console help to debug the application during development. You can access and control the logs for a more efficient debug process using the following methods.
Table of Contents
Set Log Level
The IO Operations to write logs is a considerably time-consuming task. Therefore, you need granular control over the type of log the SDK writes on browser console to:
- Get optimum log entries for debugging or audit process.
- Ensure faster communication and media flow with EnableX.
Class: EnxRtc
Method: EnxRtc.Logger.setLogLevel(Level)
Levels: 0-5
– in descending order of log detail. Default is 0.
- 0 = DEBUG
- 1 = TRACE
- 2 = INFO
- 3 = WARNING
- 4 = ERROR
- 5 = NONE
EnxRtc.Logger.setLogLevel(3); EnxRtc.Logger.setLogLevel(WARNING); // Alternate way
Get Log Dump
The Logger.setOutputFunction()
allows you to access the logs apart from the browser console such as by sending it via mail or by creating a UI.
Method: EnxRtc.Logger.setOutputFunction(Callback)
EnxRtc.Logger.setOutputFunction( function(response) {
// Use response
});
Share Log with EnableX to audit
The EnxRtc.postClientLogs()
method allows you to send latest 500 lines of console logs to EnableX using HTTP Post. You should ideally request for user’s consent before you post log to EnableX.
Method: EnxRtc.postClientLogs(Token, Callback)
if( confirm("You are posting Browser Console Log to audit.nSure?")) { room.postClientLogs(token, function(res) { Logger.info(res.message); }); }