Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

불필요한 로그 제거 #49

Merged
merged 2 commits into from
Sep 21, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: log 정리
  • Loading branch information
seohyun0120 committed Sep 21, 2024
commit c4771dde32f52da87b3ec49e47cd59f824dfa418
9 changes: 6 additions & 3 deletions src/controller/keyword.controller.ts
Original file line number Diff line number Diff line change
@@ -46,12 +46,15 @@ const getTopKeywords = async (req: Request, res: Response, next: NextFunction) =
try {
const topReactionImage: string = await MemeService.getTopReactionImage(keyword);
return { ...keyword, topReactionImage } as IKeywordWithImage;
} catch (error) {
} catch (err) {
logger.error(
`Error retrieving top reaction image for keyword: ${JSON.stringify(keyword._id)}`,
error,
err.message,
);
throw new CustomError(
`Error retrieving top reaction image for keyword: ${JSON.stringify(keyword._id)}`,
HttpCode.INTERNAL_SERVER_ERROR,
);
throw new CustomError(`Failed to get top reaction image`, HttpCode.INTERNAL_SERVER_ERROR);
}
},
);
4 changes: 2 additions & 2 deletions src/controller/keywordCategory.controller.ts
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ const updateKeywordCategory = async (req: CustomRequest, res: Response, next: Ne
updateInfo,
);
logger.info(`Updated category with ID ${req.params.categoryName}`);
return res.json(createSuccessResponse(HttpCode.OK, 'Update KeywordCategor', updatedCategory));
return res.json(createSuccessResponse(HttpCode.OK, 'Updated KeywordCategory', updatedCategory));
} catch (err) {
return next(new CustomError(err.message, err.status || HttpCode.INTERNAL_SERVER_ERROR));
}
@@ -40,7 +40,7 @@ const deleteKeywordCategory = async (req: CustomRequest, res: Response, next: Ne
const category = req.requestedKeywordCategory;
try {
await KeywordCategoryService.deleteKeywordCategory(category.name);
return res.json(createSuccessResponse(HttpCode.OK, 'Deleted KeywordCategor', true));
return res.json(createSuccessResponse(HttpCode.OK, 'Deleted KeywordCategory', true));
} catch (err) {
return next(new CustomError(err.message, err.status || HttpCode.INTERNAL_SERVER_ERROR));
}
2 changes: 1 addition & 1 deletion src/controller/meme.controller.ts
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ const getMeme = async (req: Request, res: Response, next: NextFunction) => {
}

if (!mongoose.Types.ObjectId.isValid(memeId)) {
return next(new CustomError(`'memeId' is not a valid ObjectId`, HttpCode.BAD_REQUEST));
return next(new CustomError(`${memeId} is not a valid ObjectId`, HttpCode.BAD_REQUEST));
}

try {
2 changes: 1 addition & 1 deletion src/middleware/requestedInfo.ts
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@ export const getRequestedMemeInfo = async (
}

if (!mongoose.Types.ObjectId.isValid(memeId)) {
return next(new CustomError(`'memeId' is not a valid ObjectId`, HttpCode.BAD_REQUEST));
return next(new CustomError(`${memeId} is not a valid ObjectId`, HttpCode.BAD_REQUEST));
}

const meme: IMemeDocument = await getMeme(memeId);
8 changes: 4 additions & 4 deletions src/service/keyword.service.ts
Original file line number Diff line number Diff line change
@@ -41,16 +41,16 @@ async function updateKeyword(
).lean();

if (_.isNull(updatedKeyword)) {
throw new CustomError(`Keyword with ID ${keywordId} not found`, HttpCode.NOT_FOUND);
throw new CustomError(`Keyword(${keywordId}) not found`, HttpCode.NOT_FOUND);
}

logger.info(`Update keyword - keyword(${keywordId})`);
logger.info(`Update keyword - Keyword(${keywordId})`);
return updatedKeyword;
}
async function deleteKeyword(keywordId: Types.ObjectId): Promise<boolean> {
const deletedKeyword = await KeywordModel.findOneAndDelete({ _id: keywordId }).lean();
if (_.isNull(deletedKeyword)) {
throw new CustomError(`Keyword with ID ${keywordId} not found`, HttpCode.NOT_FOUND);
throw new CustomError(`Keyword(${keywordId}) not found`, HttpCode.NOT_FOUND);
}
return true;
}
@@ -76,7 +76,7 @@ async function increaseSearchCount(keywordId: Types.ObjectId): Promise<IKeywordD
{ new: true, projection: { isDeleted: 0 } },
).lean();
if (_.isNull(updatedKeyword)) {
throw new CustomError(`KeywordId ${keywordId} not found`, HttpCode.NOT_FOUND);
throw new CustomError(`KeywordId(${keywordId}) not found`, HttpCode.NOT_FOUND);
}
return updatedKeyword;
} catch (err) {
8 changes: 3 additions & 5 deletions src/service/memeInteraction.service.ts
Original file line number Diff line number Diff line change
@@ -32,12 +32,10 @@ async function getMemeInteractionInfo(
});

return memeInteraction || null;
} catch (error) {
logger.error(`Failed to get a MemeInteraction Info(${meme._id} - ${interactionType})`, {
error,
});
} catch (err) {
logger.error(`Failed to get a MemeInteraction info(${meme._id} - ${interactionType})`);
throw new CustomError(
`Failed to get a MemeInteraction Info(${meme._id} - ${interactionType})`,
`Failed to get a MemeInteraction info(${meme._id} - ${interactionType})`,
HttpCode.INTERNAL_SERVER_ERROR,
);
}
4 changes: 2 additions & 2 deletions src/service/user.service.ts
Original file line number Diff line number Diff line change
@@ -205,8 +205,8 @@ async function getSavedMemeList(
totalPages: Math.ceil(totalSavedMemes / size),
data: savedMemeList,
};
} catch (error) {
throw new CustomError(`Failed to get saved memes`, HttpCode.INTERNAL_SERVER_ERROR, error);
} catch (err) {
throw new CustomError(`Failed to get saved memes`, HttpCode.INTERNAL_SERVER_ERROR, err);
}
}