Text FileReport added to databse. Logger format changed

This commit is contained in:
sidheshenator 2015-06-24 15:30:11 -04:00
parent 52c9e16f5a
commit 67ff3ee7cd
3 changed files with 18 additions and 2 deletions

View File

@ -25,6 +25,8 @@ import java.io.BufferedInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.file.InvalidPathException;
import java.nio.file.Paths;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
@ -1163,7 +1165,14 @@ public class Case implements SleuthkitCase.ErrorObserver {
* @throws TskCoreException * @throws TskCoreException
*/ */
public void addReport(String localPath, String srcModuleName, String reportName) throws TskCoreException { public void addReport(String localPath, String srcModuleName, String reportName) throws TskCoreException {
Report report = this.db.addReport(localPath, srcModuleName, reportName); String normalizedLocalPath;
try {
normalizedLocalPath = Paths.get(localPath).normalize().toString();
} catch (InvalidPathException ex) {
logger.log(Level.WARNING, "Invalid local path provided: " + localPath, ex);
normalizedLocalPath = localPath;
}
Report report = this.db.addReport(normalizedLocalPath, srcModuleName, reportName);
try { try {
Case.pcs.firePropertyChange(Events.REPORT_ADDED.toString(), null, report); Case.pcs.firePropertyChange(Events.REPORT_ADDED.toString(), null, report);
} catch (Exception ex) { } catch (Exception ex) {

View File

@ -79,7 +79,7 @@ public final class Logger extends java.util.logging.Logger {
+ record.getSourceMethodName() + "\n" + record.getSourceMethodName() + "\n"
+ record.getLevel() + ": " + record.getLevel() + ": "
+ this.formatMessage(record) + "\n" + this.formatMessage(record) + "\n"
+ record.getThrown().toString() + ": " + record.getThrown().toString() + ":\n"
+ StackTrace + StackTrace
+ "\n"; + "\n";
} else { } else {

View File

@ -30,7 +30,9 @@ import java.util.logging.Level;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.TskCoreException;
/** /**
* A Tab-delimited text report of the files in the case. * A Tab-delimited text report of the files in the case.
@ -68,8 +70,13 @@ import org.sleuthkit.datamodel.AbstractFile;
if (out != null) { if (out != null) {
try { try {
out.close(); out.close();
Case.getCurrentCase().addReport(reportPath, NbBundle.getMessage(this.getClass(),
"FileReportText.getName.text"), "");
} catch (IOException ex) { } catch (IOException ex) {
logger.log(Level.WARNING, "Could not close output writer when ending report.", ex); //NON-NLS logger.log(Level.WARNING, "Could not close output writer when ending report.", ex); //NON-NLS
} catch (TskCoreException ex) {
String errorMessage = String.format("Error adding %s to case as a report", reportPath); //NON-NLS
logger.log(Level.SEVERE, errorMessage, ex);
} }
} }
} }