Skip to content

Commit

Permalink
style: api logging 함수 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
BangDori committed May 2, 2024
1 parent 6a3b79b commit 7df26f2
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/shared/axios/dir/log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ export function logApiRequestOnDev(config: InternalAxiosRequestConfig) {
if (import.meta.env.DEV) {
const { method, url, data } = config;

const title = `${method?.toUpperCase()} ${url}`;

console.group(`🛫 [API 요청] ${title}`);
console.groupCollapsed(`🛫 [API 요청] ${method?.toUpperCase()} ${url}`);
console.log(`현재 시각: ${getCurrentDate()}`);
console.log(`요청 데이터: ${JSON.stringify(data, null, 2) || 'X'}`);
console.groupEnd();
Expand All @@ -28,12 +26,9 @@ export function logApiResponseOnDev(response: AxiosResponse) {
const { method, url } = config;
const { code, data } = response.data;

const title = `${method?.toUpperCase()} ${url}`;
const httpStatus = `${status} ${statusText}`;

console.group(`🛬 [API 응답] ${title}`);
console.groupCollapsed(`🛬 [API 응답] ${method?.toUpperCase()} ${url}`);
console.log(`현재 시각: ${getCurrentDate()}`);
console.log(`HTTP 응답 코드: ${httpStatus}`);
console.log(`HTTP 응답 코드: ${status} ${statusText}`);
console.log(`서버 응답 코드: ${code}`);
console.log(`서버 응답 데이터: ${JSON.stringify(data, null, 2)}`);
console.groupEnd();
Expand All @@ -45,9 +40,7 @@ export function logApiErrorOnDev(error: AxiosError) {
const { code } = error;
const { method, url } = error.config as AxiosRequestConfig;

const title = `${method?.toUpperCase()} ${url}`;

console.group(`🚨 [API 에러] ${title}`);
console.groupCollapsed(`🚨 [API 에러] ${method?.toUpperCase()} ${url}`);
console.log(`현재 시각: ${getCurrentDate()}`);
console.log(`에러 코드: ${code}`);
console.log(`에러명: ${error.message}`);
Expand Down

0 comments on commit 7df26f2

Please sign in to comment.