Logging traffic at Trace level
This commit is contained in:
parent
ceff4bd7da
commit
2cc72d72cd
|
|
@ -2,7 +2,8 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
export enum LogLevel {
|
||||
Information = 0,
|
||||
Trace = 0,
|
||||
Information,
|
||||
Warning,
|
||||
Error,
|
||||
None
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ export class WebSocketTransport implements ITransport {
|
|||
};
|
||||
|
||||
webSocket.onmessage = (message: MessageEvent) => {
|
||||
this.logger.log(LogLevel.Information, `(WebSockets transport) data received: ${message.data}`);
|
||||
this.logger.log(LogLevel.Trace, `(WebSockets transport) data received: ${message.data}`);
|
||||
if (this.onDataReceived) {
|
||||
this.onDataReceived(message.data);
|
||||
}
|
||||
|
|
@ -118,7 +118,7 @@ export class ServerSentEventsTransport implements ITransport {
|
|||
eventSource.onmessage = (e: MessageEvent) => {
|
||||
if (this.onDataReceived) {
|
||||
try {
|
||||
this.logger.log(LogLevel.Information, `(SSE transport) data received: ${e.data}`);
|
||||
this.logger.log(LogLevel.Trace, `(SSE transport) data received: ${e.data}`);
|
||||
this.onDataReceived(e.data);
|
||||
} catch (error) {
|
||||
if (this.onClosed) {
|
||||
|
|
@ -208,7 +208,7 @@ export class LongPollingTransport implements ITransport {
|
|||
: pollXhr.response;
|
||||
|
||||
if (response) {
|
||||
this.logger.log(LogLevel.Information, `(LongPolling transport) data received: ${response}`);
|
||||
this.logger.log(LogLevel.Trace, `(LongPolling transport) data received: ${response}`);
|
||||
this.onDataReceived(response);
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ describe('connection', function () {
|
|||
var message = "Hello World!";
|
||||
var connection = new signalR.HttpConnection(ECHOENDPOINT_URL, {
|
||||
transport: transportType,
|
||||
logger: signalR.LogLevel.Information
|
||||
logging: signalR.LogLevel.Trace
|
||||
});
|
||||
|
||||
var received = "";
|
||||
|
|
|
|||
|
|
@ -11,7 +11,13 @@ describe('hubConnection', function () {
|
|||
|
||||
it('can invoke server method and receive result', function (done) {
|
||||
var message = "你好,世界!";
|
||||
var hubConnection = new signalR.HubConnection(new signalR.HttpConnection(TESTHUBENDPOINT_URL, { transport: transportType }), { protocol: protocol});
|
||||
|
||||
var options = {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(new signalR.HttpConnection(TESTHUBENDPOINT_URL, options), options);
|
||||
hubConnection.onClosed = function (error) {
|
||||
expect(error).toBe(undefined);
|
||||
done();
|
||||
|
|
@ -32,7 +38,13 @@ describe('hubConnection', function () {
|
|||
});
|
||||
|
||||
it('can stream server method and receive result', function (done) {
|
||||
var hubConnection = new signalR.HubConnection(new signalR.HttpConnection(TESTHUBENDPOINT_URL, { transport: transportType }), { protocol: protocol});
|
||||
|
||||
var options = {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(new signalR.HttpConnection(TESTHUBENDPOINT_URL, options), options);
|
||||
|
||||
hubConnection.onClosed = function (error) {
|
||||
expect(error).toBe(undefined);
|
||||
|
|
@ -62,7 +74,12 @@ describe('hubConnection', function () {
|
|||
|
||||
it('rethrows an exception from the server when invoking', function (done) {
|
||||
var errorMessage = "An error occurred.";
|
||||
var hubConnection = new signalR.HubConnection(new signalR.HttpConnection(TESTHUBENDPOINT_URL, { transport: transportType }), { protocol: protocol});
|
||||
var options = {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(new signalR.HttpConnection(TESTHUBENDPOINT_URL, options), options);
|
||||
|
||||
hubConnection.start().then(function () {
|
||||
hubConnection.invoke('ThrowException', errorMessage).then(function () {
|
||||
|
|
@ -83,8 +100,12 @@ describe('hubConnection', function () {
|
|||
|
||||
it('rethrows an exception from the server when streaming', function (done) {
|
||||
var errorMessage = "An error occurred.";
|
||||
|
||||
var hubConnection = new signalR.HubConnection(new signalR.HttpConnection(TESTHUBENDPOINT_URL, { transport: transportType }), { protocol: protocol});
|
||||
var options = {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(new signalR.HttpConnection(TESTHUBENDPOINT_URL, options), options);
|
||||
|
||||
hubConnection.start().then(function () {
|
||||
hubConnection.stream('ThrowException', errorMessage).subscribe({
|
||||
|
|
@ -106,7 +127,12 @@ describe('hubConnection', function () {
|
|||
});
|
||||
|
||||
it('can receive server calls', function (done) {
|
||||
var hubConnection = new signalR.HubConnection(new signalR.HttpConnection(TESTHUBENDPOINT_URL, { transport: transportType }), { protocol: protocol});
|
||||
var options = {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(new signalR.HttpConnection(TESTHUBENDPOINT_URL, options), options);
|
||||
|
||||
var message = "你好 SignalR!";
|
||||
|
||||
|
|
@ -134,7 +160,12 @@ describe('hubConnection', function () {
|
|||
ServerSentEvents: "Error occurred"
|
||||
};
|
||||
|
||||
var hubConnection = new signalR.HubConnection(new signalR.HttpConnection('http://' + document.location.host + '/uncreatable', { transport: transportType }), { protocol: protocol});
|
||||
var options = {
|
||||
transport: transportType,
|
||||
protocol: protocol,
|
||||
logging: signalR.LogLevel.Trace
|
||||
};
|
||||
var hubConnection = new signalR.HubConnection(new signalR.HttpConnection('http://' + document.location.host + '/uncreatable', options), options);
|
||||
|
||||
hubConnection.onClosed = function (error) {
|
||||
expect(error.message).toMatch(errorRegex[signalR.TransportType[transportType]]);
|
||||
|
|
|
|||
Loading…
Reference in New Issue