From 4375e5f5de4dfc5f4fd75d8cabae2ad750f35b4a Mon Sep 17 00:00:00 2001 From: JIN Date: Wed, 6 Nov 2024 19:08:14 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20fix:=20=EC=A3=BC=EC=84=9D?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=20=ED=96=88=EB=8D=98=20=EC=BD=94=EB=93=9C?= =?UTF-8?q?=EB=A5=BC=20logger=EB=A1=9C=20=EB=B3=80=EA=B2=BD#12?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BE/src/stocks/topfive/topfive.service.ts | 34 ++++++++++++------------ 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/BE/src/stocks/topfive/topfive.service.ts b/BE/src/stocks/topfive/topfive.service.ts index 404aaf19..f2197c58 100644 --- a/BE/src/stocks/topfive/topfive.service.ts +++ b/BE/src/stocks/topfive/topfive.service.ts @@ -1,5 +1,5 @@ import axios from 'axios'; -import { Injectable } from '@nestjs/common'; +import { Injectable, Logger } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { StockRankigRequestDto } from './dto/stock-ranking-request.dto'; import { StockRankingResponseDto } from './dto/stock-ranking-response.dto'; @@ -56,6 +56,8 @@ export class TopFiveService { baseUrl: string; }; + private readonly logger = new Logger(); + constructor(private readonly config: ConfigService) { this.koreaInvestmentConfig = { appKey: this.config.get('KOREA_INVESTMENT_APP_KEY'), @@ -86,7 +88,6 @@ export class TopFiveService { } private async requestApi(params: StockRankigRequestDto) { - // eslint-disable-next-line no-useless-catch try { const token = await this.getAccessToken(); @@ -121,19 +122,18 @@ export class TopFiveService { ); return response.data; } catch (error) { - // console.error('API Error Details:', { - // status: error.response?.status, - // statusText: error.response?.statusText, - // data: error.response?.data, - // headers: error.response?.config?.headers, // 실제 요청 헤더 - // message: error.message, - // }); + this.logger.error('API Error Details:', { + status: error.response?.status, + statusText: error.response?.statusText, + data: error.response?.data, + headers: error.response?.config?.headers, + message: error.message, + }); throw error; } } async getMarketRanking(marketType: MarketType) { - // eslint-disable-next-line no-useless-catch try { const params = new StockRankigRequestDto(); params.fid_cond_mrkt_div_code = 'J'; @@ -171,13 +171,13 @@ export class TopFiveService { return response; } catch (error) { - // console.error('API Error Details:', { - // status: error.response?.status, - // statusText: error.response?.statusText, - // data: error.response?.data, - // headers: error.response?.config?.headers, // 실제 요청 헤더 - // message: error.message, - // }); + this.logger.error('API Error Details:', { + status: error.response?.status, + statusText: error.response?.statusText, + data: error.response?.data, + headers: error.response?.config?.headers, // 실제 요청 헤더 + message: error.message, + }); throw error; } }