...
The following logging levels are supported:
Level text constant | Description |
---|---|
ERROR | Errors only |
WARN | Errors and warnings |
INFO | WebSDK functions normal log (default) |
DEBUG | Debug info |
TRACE | Execution trace |
Push logs to the server
By default, client logs will no be pushed to the server. This feature can be enabled if necessary while API initializing
...
Logging enabling, disabling, level adjusting and pushing logs to the server work for custom logger as well as for default logger.
A separate logger parameters for session, stream or call
Since WebSDK build 2.0.215 it is possible to set a separate logger parameters not only for application, but also for every session, stream or call. In this case, every object uses its own logger instance. For example, let's create a separate custom loggers for stream publishing and playback in Two Way Streaming application:
1. Defaine custom loggers for publishing
Code Block | ||||
---|---|---|---|---|
| ||||
var publishCustomLogger = {
error: function (text) {
console.log("publish: ERROR:",text);
},
warn: function (text) {
console.log("publish: WARN:",text);
},
info: function (text) {
console.log("publish: INFO:",text);
},
debug: function (text) {
console.log("publish: DEBUG:",text);
},
trace: function (text) {
console.log("publish: TRACE:",text);
}
}; |
and playback
Code Block | ||||
---|---|---|---|---|
| ||||
var playCustomLogger = {
error: function (text) {
console.log("play: ERROR:",text);
},
warn: function (text) {
console.log("play: WARN:",text);
},
info: function (text) {
console.log("play: INFO:",text);
},
debug: function (text) {
console.log("play: DEBUG:",text);
},
trace: function (text) {
console.log("play: TRACE:",text);
}
}; |
2. Set custom logger option when creating Stream objects for publishing
Code Block | ||||
---|---|---|---|---|
| ||||
function publishStream() {
...
session.createStream({
name: streamName,
display: localVideo,
...,
logger: {customLogger: publishCustomLogger}
...
}).publish();
} |
and fro playback
Code Block | ||||
---|---|---|---|---|
| ||||
function playStream() {
...
session.createStream({
name: streamName,
display: remoteVideo,
logger: {customLogger: playCustomLogger}
...
}).play();
} |
3. The following messages will be displayed in browser xconsole while publishing and playing a stream in modified Two Way Streaming example