aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Gillmann <gillmann@infotropique.org>2018-06-17 14:20:39 +0000
committerNils Gillmann <gillmann@infotropique.org>2018-06-17 14:20:39 +0000
commita4763e6617dc5420939f94c0183030b94c5b010a (patch)
treeeae0aa298f355b2d85d9856a3da67f6b3eae14c1
parentb0fffb70d102642fedcfa53e85e2a14ca743472a (diff)
downloadlibextractor-python-a4763e6617dc5420939f94c0183030b94c5b010a.tar.gz
libextractor-python-a4763e6617dc5420939f94c0183030b94c5b010a.zip
attempt
Signed-off-by: Nils Gillmann <gillmann@infotropique.org>
-rw-r--r--libextractor/examples/__main__.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/libextractor/examples/__main__.py b/libextractor/examples/__main__.py
index 91bab1d..d28b6e1 100644
--- a/libextractor/examples/__main__.py
+++ b/libextractor/examples/__main__.py
@@ -35,19 +35,35 @@ faulthandler.enable()
35 35
36xtract = extractor.Extractor() 36xtract = extractor.Extractor()
37 37
38logger = logging.getLogger()
39logger.setLevel(logging.DEBUG)
40
41formatter = logging.Formater('%(asctime)s %(levelname)s - %(message)s')
42
43fh = logging.FileHandler('log.txt')
44fh.setLevel(logging.DEBUG)
45fh.setFormatter(formatter)
46logger.addHandler(fh)
47
48ch = logging.StreamHandler()
49ch.setLevel(logging.DEBUG)
50ch.setFormatter(formatter)
51logger.addHandler(ch)
52
38def print_k(xt, plugin, type, format, mime, data, datalen): 53def print_k(xt, plugin, type, format, mime, data, datalen):
39 mstr = cast(data, c_char_p) 54 mstr = cast(data, c_char_p)
40 # FIXME: this ignores 'datalen', not that great... 55 # FIXME: this ignores 'datalen', not that great...
41 # (in general, depending on the mime type and format, only 56 # (in general, depending on the mime type and format, only
42 # the first 'datalen' bytes in 'data' should be used). 57 # the first 'datalen' bytes in 'data' should be used).
43 if (format == extractor.EXTRACTOR_METAFORMAT_UTF8): 58 if (format == extractor.EXTRACTOR_METAFORMAT_UTF8):
44 print("%s - %s" % (xtract.keywordTypes()[type], mstr.value)) 59 # print("%s - %s" % (xtract.keywordTypes()[type], mstr.value))
60 logger.debug("%s - %s" % (xtract.keywordTypes()[type], mstr.value))
45 return 0 61 return 0
46 62
47def main(): 63def main():
48 # stuff 64 # stuff
49 for arg in sys.argv[1:]: 65 for arg in sys.argv[1:]:
50 print("Keywords from %s:" % arg) 66 logger.debug("Keywords from %s:" % arg)
51 xtract.extract(print_k, None, arg) 67 xtract.extract(print_k, None, arg)
52 68
53if __name__ == "__main__": 69if __name__ == "__main__":