import { ExecutionContext , Injectable , Logger , NestInterceptor , CallHandler , } from '@nestjs/common' ; import { Observable } from 'rxjs' ; import { tap } from 'rxjs/operators' ; @ Injectable ( ) export class LoggingInterceptor implements NestInterceptor { intercept ( context , next ) { const now = Date . now ( ) ; const req = context . switchToHttp ( ) . getRequest ( ) ; const method = req . method ; const url = req . url ; return next . handle ( ) . pipe ( tap ( ( ) => Logger . log ( `${ method } ${ url } ${ Date . now ( ) - now }ms` , context . getClass ( ) . name ) ) ) ; } }