Skip to content

Commit 153a99b

Browse files
authored
Merge pull request #1540 from nexB/1533-log-package-scan-exceptions
Log package scan exceptions
2 parents 25408d8 + e50765c commit 153a99b

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/scancode/api.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,23 @@
3030
from collections import OrderedDict
3131
from itertools import islice
3232
from os.path import getsize
33+
import logging
3334

3435
from commoncode.filetype import get_last_modified_date
3536
from commoncode.hash import multi_checksums
3637
from typecode.contenttype import get_type
3738

39+
40+
TRACE = False
41+
42+
logger = logging.getLogger(__name__)
43+
44+
if TRACE:
45+
import sys
46+
logging.basicConfig(stream=sys.stdout)
47+
logger.setLevel(logging.DEBUG)
48+
49+
3850
"""
3951
Main scanning functions.
4052
@@ -237,9 +249,9 @@ def get_package_info(location, **kwargs):
237249
manifest = recognize_package(location)
238250
if manifest:
239251
return dict(packages=[manifest.to_dict()])
240-
except Exception:
241-
# FIXME: this should be logged somehow, but for now we avoid useless
242-
# errors per #983
252+
except Exception as e:
253+
if TRACE:
254+
logger.error('get_package_info: {}: Exception: {}'.format(location, e))
243255
pass
244256
return dict(packages=[])
245257

0 commit comments

Comments
 (0)