diff --git a/src/main/kotlin/net/halfbinary/prettyplayerapi/controller/TrackController.kt b/src/main/kotlin/net/halfbinary/prettyplayerapi/controller/TrackController.kt index 6498c97..f2504d1 100644 --- a/src/main/kotlin/net/halfbinary/prettyplayerapi/controller/TrackController.kt +++ b/src/main/kotlin/net/halfbinary/prettyplayerapi/controller/TrackController.kt @@ -1,6 +1,7 @@ package net.halfbinary.prettyplayerapi.controller import com.mpatric.mp3agic.Mp3File +import io.github.oshai.kotlinlogging.KotlinLogging import net.halfbinary.prettyplayerapi.model.TrackInfo import net.halfbinary.prettyplayerapi.service.MusicService import org.springframework.web.bind.annotation.CrossOrigin @@ -8,6 +9,8 @@ import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.RestController +private val logger = KotlinLogging.logger {} + @RestController @CrossOrigin class TrackController(private val musicService: MusicService) { @@ -17,6 +20,7 @@ class TrackController(private val musicService: MusicService) { val trackFile = Mp3File(file) trackFile.id3v2Tag.artist trackFile.id3v2Tag.apply { + logger.debug { "Getting track $trackNumber. $title by $artist on $album" } return TrackInfo(album, artist, title) } } diff --git a/src/main/kotlin/net/halfbinary/prettyplayerapi/service/AlbumCacheService.kt b/src/main/kotlin/net/halfbinary/prettyplayerapi/service/AlbumCacheService.kt index 322100d..e42e423 100644 --- a/src/main/kotlin/net/halfbinary/prettyplayerapi/service/AlbumCacheService.kt +++ b/src/main/kotlin/net/halfbinary/prettyplayerapi/service/AlbumCacheService.kt @@ -37,6 +37,7 @@ class AlbumCacheService(private val albumRepository: AlbumRepository) { } suspend fun cacheAlbums(refresh: Boolean = false) { + logger.debug { "Starting the cache process with refresh set to $refresh" } createAlbumArtRootDir() val list = getAlbumRootDir() .walkTopDown() @@ -56,6 +57,7 @@ class AlbumCacheService(private val albumRepository: AlbumRepository) { } albumRepository.albumCache = convertAlbumListToMapForCache(list) + //TODO: Write cache to file for later reading...or get a DB going? logger.info { "Albums cached: ${albumRepository.albumCache.size}" } } @@ -83,8 +85,8 @@ class AlbumCacheService(private val albumRepository: AlbumRepository) { } suspend fun getAndWriteAlbumImageFile(file: File, folderHash: String, folder: Path, refresh: Boolean = false) { + logger.info { "Checking album $folder with hash $folderHash" } val hashedFile = File("$ALBUM_ART_ROOT_DIR/$folderHash.jpg") - logger.info { "Looking at $hashedFile" } if(refresh || !hashedFile.exists()) { logger.debug { "No image for $folder, making one..." } val imageByteStream = Mp3File(file).id3v2Tag.albumImage.inputStream() @@ -93,7 +95,7 @@ class AlbumCacheService(private val albumRepository: AlbumRepository) { val outputImage = BufferedImage(300, 300, BufferedImage.TYPE_INT_RGB) outputImage.graphics.drawImage(scaledImage, 0, 0, null) ImageIO.write(outputImage, "jpg", hashedFile) - logger.debug { "Wrote new image file." } + logger.trace { "Wrote new image file for $folder with hash $folderHash" } } } diff --git a/src/main/kotlin/net/halfbinary/prettyplayerapi/service/StartupService.kt b/src/main/kotlin/net/halfbinary/prettyplayerapi/service/StartupService.kt index 2869621..ea134f5 100644 --- a/src/main/kotlin/net/halfbinary/prettyplayerapi/service/StartupService.kt +++ b/src/main/kotlin/net/halfbinary/prettyplayerapi/service/StartupService.kt @@ -17,7 +17,6 @@ class StartupService(private val albumCacheService: AlbumCacheService) { suspend fun onStartup() { coroutineScope { launch { - logger.info { "Starting up..." } albumCacheService.doAlbumCache() } } diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000..eea02f8 --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,11 @@ + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + +