Skip to content

Commit

Permalink
Merge pull request #1275 from sidheshenator/python_logging
Browse files Browse the repository at this point in the history
python logger logs appropriate logging source
  • Loading branch information
rcordovano committed May 27, 2015
2 parents 930dc8c + abe801e commit c0b1d20
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions pythonExamples/dataSourceIngestModule.py
Expand Up @@ -33,6 +33,7 @@

import jarray
from java.lang import System
from java.util.logging import Level
from org.sleuthkit.datamodel import SleuthkitCase
from org.sleuthkit.datamodel import AbstractFile
from org.sleuthkit.datamodel import ReadContentInputStream
Expand Down Expand Up @@ -113,7 +114,7 @@ def process(self, dataSource, progressBar):
files = fileManager.findFiles(dataSource, "%test%")

numFiles = len(files)
logger.info("found " + str(numFiles) + " files")
logger.logp(Level.INFO, SampleJythonDataSourceIngestModule.__name__, "process", "found " + str(numFiles) + " files")
progressBar.switchToDeterminate(numFiles)
fileCount = 0;
for file in files:
Expand All @@ -122,7 +123,7 @@ def process(self, dataSource, progressBar):
if self.context.isJobCancelled():
return IngestModule.ProcessResult.OK

logger.info("Processing file: " + file.getName())
logger.logp(Level.INFO, SampleJythonDataSourceIngestModule.__name__, "process", "Processing file: " + file.getName())
fileCount += 1

# Make an artifact on the blackboard. TSK_INTERESTING_FILE_HIT is a generic type of
Expand Down
3 changes: 2 additions & 1 deletion pythonExamples/fileIngestModule.py
Expand Up @@ -33,6 +33,7 @@

import jarray
from java.lang import System
from java.util.logging import Level
from org.sleuthkit.datamodel import SleuthkitCase
from org.sleuthkit.datamodel import AbstractFile
from org.sleuthkit.datamodel import ReadContentInputStream
Expand Down Expand Up @@ -99,7 +100,7 @@ def process(self, file):
# For an example, we will flag files with .txt in the name and make a blackboard artifact.
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

# Make an artifact on the blackboard. TSK_INTERESTING_FILE_HIT is a generic type of
Expand Down
7 changes: 4 additions & 3 deletions pythonExamples/fileIngestModuleWithGui.py
Expand Up @@ -40,6 +40,7 @@

import jarray
from java.lang import System
from java.util.logging import Level
from javax.swing import JCheckBox
from javax.swing import BoxLayout
from org.sleuthkit.autopsy.casemodule import Case
Expand Down Expand Up @@ -117,12 +118,12 @@ def __init__(self, settings):
# TODO: Add any setup code that you need here.
def startUp(self, context):
self.logger = Logger.getLogger(SampleFileIngestModuleWithUIFactory.moduleName)

# As an example, determine if user configured a flag in UI
if self.local_settings.getFlag():
self.logger.info("flag is set")
self.logger.logp(Level.INFO, SampleFileIngestModuleWithUI.__name__, "startUp", "flag is set")
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
# raise IngestModuleException(IngestModule(), "Oh No!")
Expand Down

0 comments on commit c0b1d20

Please sign in to comment.