Fixed errors related to logging

This commit is contained in:
Eugene Livis 2016-01-14 12:39:48 -05:00
parent 4548f7605e
commit 1d40794bcf

View File

@ -92,7 +92,7 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter {
// Not sure how long it will take for search to complete. // Not sure how long it will take for search to complete.
progressBar.switchToIndeterminate(); progressBar.switchToIndeterminate();
logger.log(Level.INFO, "Looking for virtual machine files in data source %s", dataSource.getName()); logger.log(Level.INFO, "Looking for virtual machine files in data source {0}", dataSource.getName());
try { try {
// look for all VM files // look for all VM files
@ -104,7 +104,7 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter {
if (vmFiles.isEmpty()) { if (vmFiles.isEmpty()) {
// no VM files found // no VM files found
logger.log(Level.INFO, "No virtual machine files found in data source %s", dataSource.getName()); logger.log(Level.INFO, "No virtual machine files found in data source {0}", dataSource.getName());
return ProcessResult.OK; return ProcessResult.OK;
} }
// display progress for saving each VM file to disk // display progress for saving each VM file to disk
@ -117,7 +117,7 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter {
break; break;
} }
logger.log(Level.INFO, "Saving virtual machine file %s to disk", vmFile.getName()); logger.log(Level.INFO, "Saving virtual machine file {0} to disk", vmFile.getName());
// get vmFolderPathInsideTheImage to the folder where VM is located // get vmFolderPathInsideTheImage to the folder where VM is located
String vmFolderPathInsideTheImage = vmFile.getParentPath(); String vmFolderPathInsideTheImage = vmFile.getParentPath();
@ -139,7 +139,7 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter {
try { try {
writeVirtualMachineToDisk(vmFile, outputFolderForThisVM); writeVirtualMachineToDisk(vmFile, outputFolderForThisVM);
} catch (Exception ex) { } catch (Exception ex) {
logger.log(Level.SEVERE, String.format("Failed to write virtual machine file %s (id=%d) to disk", vmFile.getName(), vmFile.getId()), ex); logger.log(Level.SEVERE, "Failed to write virtual machine file "+vmFile.getName()+" to folder "+outputFolderForThisVM, ex);
MessageNotifyUtil.Notify.error("Failed to extract virtual machine file", String.format("Failed to write virtual machine file %s to disk", vmFile.getName())); MessageNotifyUtil.Notify.error("Failed to extract virtual machine file", String.format("Failed to write virtual machine file %s to disk", vmFile.getName()));
} }
@ -161,22 +161,23 @@ final class VMExtractorIngestModule extends DataSourceIngestModuleAdapter {
List<String> vmFilesToIngest = VirtualMachineFinderUtility.identifyVirtualMachines(Paths.get(folder)); List<String> vmFilesToIngest = VirtualMachineFinderUtility.identifyVirtualMachines(Paths.get(folder));
for (String file : vmFilesToIngest) { for (String file : vmFilesToIngest) {
try { try {
logger.log(Level.INFO, String.format("Ingesting virtual machine file %s in folder %s", file, folder)); logger.log(Level.INFO, "Ingesting virtual machine file {0} in folder {1}", new Object[]{file, folder});
// ingest the data sources // ingest the data sources
ingestVirtualMachineImage(Paths.get(folder, file)); ingestVirtualMachineImage(Paths.get(folder, file));
logger.log(Level.INFO, String.format("Ingest complete for virtual machine file %s in folder %s", file, folder)); logger.log(Level.INFO, "Ingest complete for virtual machine file {0} in folder {1}", new Object[]{file, folder});
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
logger.log(Level.INFO, String.format("Interrupted while adding virtual machine file %s in folder %s", file, folder), ex); logger.log(Level.INFO, "Interrupted while ingesting virtual machine file "+file+" in folder "+folder, ex);
} catch (IOException ex) { } catch (IOException ex) {
logger.log(Level.SEVERE, String.format("Failed to write virtual machine file %s to disk", file), ex); logger.log(Level.SEVERE, "Failed to ingest virtual machine file "+file+" in folder "+folder, ex);
MessageNotifyUtil.Notify.error("Failed to extract virtual machine file", String.format("Failed to write virtual machine file %s to disk", file)); MessageNotifyUtil.Notify.error("Failed to ingest virtual machine", String.format("Failed to ingest virtual machine file %s", file));
} }
} }
// Update progress bar // Update progress bar
numJobsQueued++; numJobsQueued++;
progressBar.progress(NbBundle.getMessage(this.getClass(), "VMExtractorIngestModule.queuingIngestJobs.message"), numJobsQueued); progressBar.progress(NbBundle.getMessage(this.getClass(), "VMExtractorIngestModule.queuingIngestJobs.message"), numJobsQueued);
} }
logger.log(Level.INFO, "VMExtractorIngestModule completed processing of data source %s", dataSource.getName()); logger.log(Level.INFO, "VMExtractorIngestModule completed processing of data source {0}", dataSource.getName());
return ProcessResult.OK; return ProcessResult.OK;
} }