Skip to content

Commit 3f1a283

Browse files
committed
Improved log of warnings
1 parent 7e045bb commit 3f1a283

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

swift_code_metrics/_helpers.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
import re
2+
import logging
3+
4+
5+
class Log:
6+
__logger = logging.getLogger(__name__)
7+
8+
@classmethod
9+
def warn(cls, message: str):
10+
Log.__logger.warning(message)
211

312

413
class AnalyzerHelpers:

swift_code_metrics/_metrics.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from ._helpers import AnalyzerHelpers
2+
from ._helpers import Log
23
from functional import seq
3-
from warnings import warn
44

55

66
class Metrics:
@@ -32,7 +32,7 @@ def instability(framework, frameworks):
3232
fan_out = Metrics.fan_out(framework)
3333
sum_in_out = fan_in + fan_out
3434
if sum_in_out == 0:
35-
warn(f'{framework.name} is not linked with the rest of the project.', Warning)
35+
Log.warn(f'{framework.name} is not linked with the rest of the project.')
3636
return 0
3737
return fan_out / sum_in_out
3838

@@ -46,7 +46,7 @@ def abstractness(framework):
4646
:return: The abstractness value (double)
4747
"""
4848
if framework.number_of_concrete_data_structures == 0:
49-
warn(f'{framework.name} is an external dependency.', Warning)
49+
Log.warn(f'{framework.name} is an external dependency.')
5050
return 0
5151
else:
5252
return framework.number_of_interfaces / framework.number_of_concrete_data_structures

0 commit comments

Comments
 (0)