Skip to content

Commit 953570f

Browse files
authored
Merge pull request #94 from NMNB-Team/v1/feat/#93-thumbnail-log
[feat] 썸네일 처리 로직에 상세 로그 추가
2 parents 4b19903 + 1cef567 commit 953570f

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

  • nmnb-webflux/src/main/kotlin/nmnb/webflux/global/infrastructure/external/redis

nmnb-webflux/src/main/kotlin/nmnb/webflux/global/infrastructure/external/redis/ThumbnailWorker.kt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ class ThumbnailWorker(
4646
.awaitSingleOrNull()
4747

4848
if (payload != null) {
49+
logger.info("Received payload from queue---------")
4950
processPayload(payload)
51+
logger.info("Finished payload from queue---------")
5052
} else {
53+
logger.info("No payload in queue")
5154
delay(1000)
5255
}
5356
} catch (e: Exception) {
@@ -65,31 +68,44 @@ class ThumbnailWorker(
6568
val accessStrategy = job.accessStrategy
6669

6770
val thumbnailFile = createThumbnail(fileName)
71+
logger.info("Thumbnail created for file: $fileName")
72+
6873
val thumbnailUrl = s3Service.uploadThumbnail(fileName, thumbnailFile, accessStrategy)
74+
logger.info("Thumbnail updated to S3: $thumbnailUrl")
6975

7076
updatePostThumbnail(postId, thumbnailUrl)
77+
logger.info("Post updated with thumbnail url")
7178

72-
thumbnailFile.delete()
79+
if (thumbnailFile.delete()) {
80+
logger.info("Temporary thumbnail file deleted : ${thumbnailFile.absolutePath}")
81+
} else {
82+
logger.warn("Failed to delete temporary thumbnail file : ${thumbnailFile.absolutePath}")
83+
}
7384
}
7485

7586
private suspend fun createThumbnail(fileName: String): File =
7687
coroutineScope {
88+
logger.info("Starting thumbnail creation for video file : $fileName")
7789
val videoDownload = async { s3Service.download(fileName) }
7890
val thumbnailGeneration = async {
7991
val localVideoFile = videoDownload.await()
8092
ffmpegService.createThumbnail(localVideoFile)
8193
}
8294

8395
val thumbnailFile = thumbnailGeneration.await()
96+
logger.info("Thumbnail generation completed for file : $fileName")
8497

8598
thumbnailFile
8699
}
87100

88101
private suspend fun updatePostThumbnail(postId: Long, thumbnailUrl: String) {
89102
val post = postRepository.findById(postId).awaitSingleOrNull()
90-
post?.let {
91-
val updated = it.updateThumbnail(thumbnailUrl)
103+
if (post != null) {
104+
val updated = post.updateThumbnail(thumbnailUrl)
92105
postRepository.save(updated).awaitSingle()
106+
logger.info("post $postId successfully updated")
107+
} else {
108+
logger.warn("Post $postId not found")
93109
}
94110
}
95111

0 commit comments

Comments
 (0)