python logger logs appropriate logging source

This commit is contained in:
sidheshenator 2015-05-26 14:39:55 -04:00
parent ad779792e0
commit abe801e151
3 changed files with 9 additions and 6 deletions

View File

@ -33,6 +33,7 @@
import jarray import jarray
from java.lang import System from java.lang import System
from java.util.logging import Level
from org.sleuthkit.datamodel import SleuthkitCase from org.sleuthkit.datamodel import SleuthkitCase
from org.sleuthkit.datamodel import AbstractFile from org.sleuthkit.datamodel import AbstractFile
from org.sleuthkit.datamodel import ReadContentInputStream from org.sleuthkit.datamodel import ReadContentInputStream
@ -113,7 +114,7 @@ class SampleJythonDataSourceIngestModule(DataSourceIngestModule):
files = fileManager.findFiles(dataSource, "%test%") files = fileManager.findFiles(dataSource, "%test%")
numFiles = len(files) numFiles = len(files)
logger.info("found " + str(numFiles) + " files") logger.logp(Level.INFO, SampleJythonDataSourceIngestModule.__name__, "process", "found " + str(numFiles) + " files")
progressBar.switchToDeterminate(numFiles) progressBar.switchToDeterminate(numFiles)
fileCount = 0; fileCount = 0;
for file in files: for file in files:
@ -122,7 +123,7 @@ class SampleJythonDataSourceIngestModule(DataSourceIngestModule):
if self.context.isJobCancelled(): if self.context.isJobCancelled():
return IngestModule.ProcessResult.OK return IngestModule.ProcessResult.OK
logger.info("Processing file: " + file.getName()) logger.logp(Level.INFO, SampleJythonDataSourceIngestModule.__name__, "process", "Processing file: " + file.getName())
fileCount += 1 fileCount += 1
# Make an artifact on the blackboard. TSK_INTERESTING_FILE_HIT is a generic type of # Make an artifact on the blackboard. TSK_INTERESTING_FILE_HIT is a generic type of

View File

@ -33,6 +33,7 @@
import jarray import jarray
from java.lang import System from java.lang import System
from java.util.logging import Level
from org.sleuthkit.datamodel import SleuthkitCase from org.sleuthkit.datamodel import SleuthkitCase
from org.sleuthkit.datamodel import AbstractFile from org.sleuthkit.datamodel import AbstractFile
from org.sleuthkit.datamodel import ReadContentInputStream from org.sleuthkit.datamodel import ReadContentInputStream
@ -99,7 +100,7 @@ class SampleJythonFileIngestModule(FileIngestModule):
# For an example, we will flag files with .txt in the name and make a blackboard artifact. # For an example, we will flag files with .txt in the name and make a blackboard artifact.
if file.getName().find(".txt") != -1: if file.getName().find(".txt") != -1:
self.logger.info("Found a text file: " + file.getName()) self.logger.logp(Level.INFO, SampleJythonFileIngestModule.__name__, "process", "Found a text file: " + file.getName())
self.filesFound+=1 self.filesFound+=1
# Make an artifact on the blackboard. TSK_INTERESTING_FILE_HIT is a generic type of # Make an artifact on the blackboard. TSK_INTERESTING_FILE_HIT is a generic type of

View File

@ -40,6 +40,7 @@
import jarray import jarray
from java.lang import System from java.lang import System
from java.util.logging import Level
from javax.swing import JCheckBox from javax.swing import JCheckBox
from javax.swing import BoxLayout from javax.swing import BoxLayout
from org.sleuthkit.autopsy.casemodule import Case from org.sleuthkit.autopsy.casemodule import Case
@ -117,12 +118,12 @@ class SampleFileIngestModuleWithUI(FileIngestModule):
# TODO: Add any setup code that you need here. # TODO: Add any setup code that you need here.
def startUp(self, context): def startUp(self, context):
self.logger = Logger.getLogger(SampleFileIngestModuleWithUIFactory.moduleName) self.logger = Logger.getLogger(SampleFileIngestModuleWithUIFactory.moduleName)
# As an example, determine if user configured a flag in UI # As an example, determine if user configured a flag in UI
if self.local_settings.getFlag(): if self.local_settings.getFlag():
self.logger.info("flag is set") self.logger.logp(Level.INFO, SampleFileIngestModuleWithUI.__name__, "startUp", "flag is set")
else: else:
self.logger.info("flag is not set") self.logger.logp(Level.INFO, SampleFileIngestModuleWithUI.__name__, "startUp", "flag is not set")
# Throw an IngestModule.IngestModuleException exception if there was a problem setting up # Throw an IngestModule.IngestModuleException exception if there was a problem setting up
# raise IngestModuleException(IngestModule(), "Oh No!") # raise IngestModuleException(IngestModule(), "Oh No!")