Skip to content

Commit

Permalink
Add more logging to ModWriter and CustomFurnitureModWriter.
Browse files Browse the repository at this point in the history
  • Loading branch information
quincyjo committed Feb 2, 2025
1 parent adb4cbe commit a6ffa94
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import java.awt.image.BufferedImage
import java.io.FileOutputStream
import javax.imageio.ImageIO
import scala.reflect.io.{Directory, File, Path}
import scala.util.chaining.scalaUtilChainingOps

/** Trait defining a writer for a SMAPI mod.
* @tparam ModType
Expand Down Expand Up @@ -62,6 +63,9 @@ trait ModWriter[ModType] {
logger.debug(s"Writing ${file.name}")
new FileOutputStream(file.jfile).getChannel
.write(jsonPrinter.printToByteBuffer(json.deepDropNullValues))
.tap { bytesWritten =>
logger.debug(s"Successfully Wrote $bytesWritten bytes to ${file.name}")
}
}

/** Writes the given JSON to the given path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ class CustomFurnitureModWriter(mod: CustomFurnitureMod)
writeAsJson(in, "manifest", mod.manifest)

override def writeTo(root: Directory): Unit = {
if (!root.exists) root.createDirectory()
if (!root.exists) {
logger.info(
s"Target directory does not exist. Creating directory ${root.name}"
)
root.createDirectory()
}
logger.info(s"Writing mod ${mod.manifest.name} to ${root.name}")
writeManifest(root)
writeAsJson(
root,
Expand Down

0 comments on commit a6ffa94

Please sign in to comment.