mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
fix(websockets): fix subscription logs
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Type } from '@nestjs/common/interfaces/type.interface';
|
||||
import { isFunction } from '@nestjs/common/utils/shared.utils';
|
||||
import { Logger } from '@nestjs/common/services/logger.service';
|
||||
import { isFunction } from '@nestjs/common/utils/shared.utils';
|
||||
import { ApplicationConfig } from '@nestjs/core/application-config';
|
||||
import { MetadataScanner } from '@nestjs/core/metadata-scanner';
|
||||
import { from as fromPromise, Observable, of, Subject } from 'rxjs';
|
||||
@@ -93,6 +93,7 @@ export class WebSocketsController {
|
||||
connection,
|
||||
);
|
||||
adapter.bindClientConnect(server, handler);
|
||||
this.printSubscriptionLogs(instance, subscribersMap);
|
||||
}
|
||||
|
||||
public getConnectionHandler(
|
||||
@@ -184,4 +185,19 @@ export class WebSocketsController {
|
||||
Reflect.set(instance, propertyKey, server);
|
||||
}
|
||||
}
|
||||
|
||||
private printSubscriptionLogs(
|
||||
instance: NestGateway,
|
||||
subscribersMap: MessageMappingProperties[],
|
||||
) {
|
||||
const gatewayClassName = (instance as Object)?.constructor?.name;
|
||||
if (!gatewayClassName) {
|
||||
return;
|
||||
}
|
||||
subscribersMap.forEach(({ message }) =>
|
||||
this.logger.log(
|
||||
`${gatewayClassName} subscribed to the "${message}" message`,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user