From 3a04b500607dbf394be80aa9c0abc692320818e4 Mon Sep 17 00:00:00 2001 From: Jeremy Yin Date: Wed, 19 Jun 2019 23:06:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E4=B8=80=E4=B8=AApi?= =?UTF-8?q?pe=E6=89=93=E5=8D=B0=E5=A4=84=E7=90=86=E5=AE=8Chandler=E7=9A=84?= =?UTF-8?q?=E8=80=97=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/interceptors/logging.interceptor.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core/interceptors/logging.interceptor.ts b/src/core/interceptors/logging.interceptor.ts index 26a3c1b..069d4eb 100644 --- a/src/core/interceptors/logging.interceptor.ts +++ b/src/core/interceptors/logging.interceptor.ts @@ -1,11 +1,21 @@ import { CallHandler, ExecutionContext, Injectable, NestInterceptor } from '@nestjs/common'; import { Observable } from 'rxjs'; +import { tap } from 'rxjs/operators' @Injectable() export class LoggingInterceptor implements NestInterceptor { intercept(context: ExecutionContext, next: CallHandler): Observable { console.log('I am a interceptor!') + + const now = Date.now(); + console.log('before...'); + + - return next.handle(); + return next + .handle() + .pipe( + tap(() => console.log(`after... ${Date.now() - now}ms`)) + ); } }