From 17688dcb1778497128fe95b7bbc2db91af587bb4 Mon Sep 17 00:00:00 2001 From: Drew Short Date: Tue, 28 Jan 2014 21:13:15 -0600 Subject: [PATCH] Added some additional logging at the INFO level. Fixed the default Log4J.properties file to only output INFO and above to the console. --- buildWithoutTests.sh | 2 ++ src/includes/log4j.properties | 1 + src/includes/startCLI.sh | 2 +- src/includes/startGUI.sh | 4 ++-- .../java/com/sothr/imagetools/AppCLI.java | 2 +- .../scala/com/sothr/imagetools/Engine.scala | 11 +++++++--- .../com/sothr/imagetools/image/Image.scala | 3 ++- .../sothr/imagetools/image/ImageService.scala | 21 ++++++++++++------- 8 files changed, 31 insertions(+), 15 deletions(-) create mode 100755 buildWithoutTests.sh diff --git a/buildWithoutTests.sh b/buildWithoutTests.sh new file mode 100755 index 0000000..a0785c7 --- /dev/null +++ b/buildWithoutTests.sh @@ -0,0 +1,2 @@ +#!/bin/bash +mvn -Dmaven.test.skip=true clean jfx:jar diff --git a/src/includes/log4j.properties b/src/includes/log4j.properties index 337329d..09e024a 100644 --- a/src/includes/log4j.properties +++ b/src/includes/log4j.properties @@ -2,6 +2,7 @@ log4j.rootLogger=DEBUG, C, DL, IL, EL # Console Output log4j.appender.C=org.apache.log4j.ConsoleAppender +log4j.appender.C.Threshold=INFO log4j.appender.C.layout=org.apache.log4j.EnhancedPatternLayout log4j.appender.C.layout.ConversionPattern=%d{yy-MM-dd HH:mm:ss} %-5p [%c{3.}] - %m%n diff --git a/src/includes/startCLI.sh b/src/includes/startCLI.sh index 5a37e77..4b67034 100755 --- a/src/includes/startCLI.sh +++ b/src/includes/startCLI.sh @@ -4,7 +4,7 @@ command="" correct=false while true; do read -p "Please enter and commandline arguments you would like to include: " args - command="-Xmx1.5G -cp ${project.name}-${project.version}-jfx.jar:lib/* com.sothr.imagetools.AppCLI $args" + command="-Xmx1500m -cp ${project.name}-${project.version}-jfx.jar:lib/* com.sothr.imagetools.AppCLI $args" echo "Is \"$command\" accurate? (yes/no)" select yn in "Yes" "No"; do case $yn in diff --git a/src/includes/startGUI.sh b/src/includes/startGUI.sh index dcb6693..af6b315 100755 --- a/src/includes/startGUI.sh +++ b/src/includes/startGUI.sh @@ -1,4 +1,4 @@ #!/bin/bash echo "Welcome to Image Tools version: ${project.version}" -command="-Xmx1.5G -jar ${project.name}-${project.version}-jfx.jar" -java $command \ No newline at end of file +command="-Xmx1500m -jar ${project.name}-${project.version}-jfx.jar" +java $command diff --git a/src/main/java/com/sothr/imagetools/AppCLI.java b/src/main/java/com/sothr/imagetools/AppCLI.java index 5e0cf72..7c69647 100644 --- a/src/main/java/com/sothr/imagetools/AppCLI.java +++ b/src/main/java/com/sothr/imagetools/AppCLI.java @@ -27,7 +27,7 @@ class AppCLI { CommandLine cmd = parser.parse(options, args); process(cmd); } catch (Exception ex) { - logger.error("Unhandled exception in AppCLI", ex); + logger.error("Unhandled exception in AppCLI",ex); } } diff --git a/src/main/scala/com/sothr/imagetools/Engine.scala b/src/main/scala/com/sothr/imagetools/Engine.scala index 2f27e73..c8f0825 100644 --- a/src/main/scala/com/sothr/imagetools/Engine.scala +++ b/src/main/scala/com/sothr/imagetools/Engine.scala @@ -18,16 +18,21 @@ class Engine() extends Logging{ debug(s"Looking for images in directory: $directoryPath") val images:mutable.MutableList[Image] = new mutable.MutableList[Image]() val directory:File = new File(directoryPath) + var count = 0 if (directory.isDirectory) { val files = directory.listFiles(imageFilter) - debug(s"Found ${files.length} files that are images in directory: $directoryPath") + info(s"Found ${files.length} files that are images in directory: $directoryPath") for (file <- files) { + count += 1 + if (count % 25 == 0) info(s"Processed ${count}/${files.size}") if (imageCache.isKeyInCache(file.getAbsolutePath)) { images += imageCache.get(file.getAbsolutePath).getObjectValue.asInstanceOf[Image] } else { val image = ImageService.getImage(file) - imageCache.put(new Element(file.getAbsolutePath, image)) - images += image + if (image != null) { + imageCache.put(new Element(file.getAbsolutePath, image)) + images += image + } } } } else { diff --git a/src/main/scala/com/sothr/imagetools/image/Image.scala b/src/main/scala/com/sothr/imagetools/image/Image.scala index 7f18119..4d15e16 100644 --- a/src/main/scala/com/sothr/imagetools/image/Image.scala +++ b/src/main/scala/com/sothr/imagetools/image/Image.scala @@ -2,8 +2,9 @@ package com.sothr.imagetools.image import com.sothr.imagetools.dto.ImageHashDTO import com.sothr.imagetools.hash.HashService +import grizzled.slf4j.Logging -class Image(val imagePath:String, val thumbnailPath:String, val imageSize:Tuple2[Int,Int], var hashes:ImageHashDTO = null) { +class Image(val imagePath:String, val thumbnailPath:String, val imageSize:Tuple2[Int,Int], var hashes:ImageHashDTO = null) extends Serializable with Logging{ var imageType:ImageType = ImageType.SingleFrameImage diff --git a/src/main/scala/com/sothr/imagetools/image/ImageService.scala b/src/main/scala/com/sothr/imagetools/image/ImageService.scala index 27e2ef2..561eb3f 100644 --- a/src/main/scala/com/sothr/imagetools/image/ImageService.scala +++ b/src/main/scala/com/sothr/imagetools/image/ImageService.scala @@ -7,17 +7,24 @@ import java.io.File import com.sothr.imagetools.image.Image import com.sothr.imagetools.hash.HashService import javax.imageio.ImageIO +import java.io.IOException object ImageService extends Logging { def getImage(file:File):Image = { - val thumbnailPath = getThumbnailPath(file) - val bufferedImage = ImageIO.read(file) - val hashes = HashService.getImageHashes(bufferedImage, file.getAbsolutePath) - val imageSize = { (bufferedImage.getWidth, bufferedImage.getHeight) } - val image = new Image(file.getAbsolutePath, thumbnailPath, imageSize, hashes) - debug(s"Created image: $image") - image + try { + val thumbnailPath = getThumbnailPath(file) + val bufferedImage = ImageIO.read(file) + val hashes = HashService.getImageHashes(bufferedImage, file.getAbsolutePath) + val imageSize = { (bufferedImage.getWidth, bufferedImage.getHeight) } + val image = new Image(file.getAbsolutePath, thumbnailPath, imageSize, hashes) + debug(s"Created image: $image") + return image + } catch { + case ioe:IOException => error(s"Error processing ${file.getAbsolutePath}", ioe) + case ex:Exception => error(s"Error processing ${file.getAbsolutePath}", ex) + } + null } def getThumbnailPath(file:File):String = {