Skip to content

Commit d4ec867

Browse files
committed
Improve tracing
Signed-off-by: Philippe Ombredanne <[email protected]>
1 parent 61b65ff commit d4ec867

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/licensedcode/index.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ def match_query(
991991
for matcher, include_low, matcher_name in matchers:
992992
if TRACE:
993993
logger_debug()
994-
logger_debug('matching with matcher:', matcher_name)
994+
logger_debug('match_query: matching with matcher:', matcher_name)
995995

996996
matched = matcher(
997997
qry,
@@ -1019,7 +1019,7 @@ def match_query(
10191019
):
10201020
qry.subtract(m.qspan)
10211021

1022-
# Check if we have some matchable left do not match futher if we do
1022+
# Check if we have some matchable left: do not match futher if we do
10231023
# not need to collect qspans matched exactly e.g. with coverage 100%
10241024
# this coverage check is because we have provision to match
10251025
# fragments (unused for now).
@@ -1028,7 +1028,11 @@ def match_query(
10281028
m.qspan for m in matched if m.coverage() == 100)
10291029

10301030
if not whole_query_run.is_matchable(
1031-
include_low=include_low, qspans=already_matched_qspans):
1031+
include_low=include_low,
1032+
qspans=already_matched_qspans,
1033+
):
1034+
if TRACE:
1035+
logger_debug(' match_query: no more matchable ... stop matching after matcher:', matcher_name)
10321036
break
10331037

10341038
# break if deadline has passed

src/licensedcode/match_seq.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,20 @@ def logger_debug(*args): pass
2424

2525

2626
if TRACE or TRACE2 or TRACE3:
27-
import logging
28-
29-
logger = logging.getLogger(__name__)
27+
use_print = True
28+
if use_print:
29+
prn = print
30+
else:
31+
import logging
32+
logger = logging.getLogger(__name__)
33+
# logging.basicConfig(level=logging.DEBUG, stream=sys.stdout)
34+
logging.basicConfig(stream=sys.stdout)
35+
logger.setLevel(logging.DEBUG)
36+
prn = logger.debug
3037

3138
def logger_debug(*args):
32-
return logger.debug(' '.join(isinstance(a, str) and a or repr(a) for a in args))
39+
return prn(' '.join(isinstance(a, str) and a or repr(a) for a in args))
3340

34-
logging.basicConfig(stream=sys.stdout)
35-
logger.setLevel(logging.DEBUG)
3641

3742
"""
3843
Matching strategy using pair-wise multiple local sequences alignment and diff-

0 commit comments

Comments
 (0)