Skip to content

Commit 5d679ba

Browse files
authored
Merge init_log & init_log_item functions
2 parents f12514a + 1b0a0f4 commit 5d679ba

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

src/fosslight_source/convert_scancode.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import logging
1212
import fosslight_util.constant as constant
1313
from fosslight_util.set_log import init_log
14-
from fosslight_util.set_log import init_log_item
1514
import yaml
1615
from ._parsing_scancode_file_item import parsing_file_item, get_error_from_header
1716
from fosslight_util.write_excel import write_excel_and_csv
@@ -21,9 +20,8 @@
2120
_PKG_NAME = "fosslight_source"
2221

2322

24-
def convert_json_to_excel(scancode_json, excel_name):
23+
def convert_json_to_excel(scancode_json, excel_name, _result_log):
2524
file_list = []
26-
_result_log = init_log_item(_PKG_NAME)
2725
msg = ""
2826
success = True
2927

@@ -117,9 +115,9 @@ def main():
117115
oss_report_name = output_file_name
118116
output_dir = os.path.dirname(os.path.abspath(output_file_name))
119117

120-
logger = init_log(os.path.join(output_dir, "fosslight_src_log_" + start_time + ".txt"))
121-
122-
convert_json_to_excel(path_to_find_bin, oss_report_name)
118+
logger, _result_log = init_log(os.path.join(output_dir, "fosslight_src_log_" + start_time + ".txt"),
119+
True, logging.INFO, logging.DEBUG, _PKG_NAME)
120+
convert_json_to_excel(path_to_find_bin, oss_report_name, _result_log)
123121

124122

125123
if __name__ == '__main__':

src/fosslight_source/run_scancode.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from datetime import datetime
1616
import fosslight_util.constant as constant
1717
from fosslight_util.set_log import init_log
18-
from fosslight_util.set_log import init_log_item
1918
from fosslight_util.timer_thread import TimerThread
2019
from ._parsing_scancode_file_item import parsing_file_item
2120
from ._parsing_scancode_file_item import get_error_from_header
@@ -76,8 +75,8 @@ def run_scan(path_to_scan, output_file_name="",
7675
output_json_file = output_file_name
7776
output_dir = os.path.dirname(os.path.abspath(output_file_name))
7877

79-
logger = init_log(os.path.join(output_dir, "fosslight_src_log_"+start_time+".txt"))
80-
_result_log = init_log_item(_PKG_NAME, path_to_scan)
78+
logger, _result_log = init_log(os.path.join(output_dir, "fosslight_src_log_"+start_time+".txt"),
79+
True, logging.INFO, logging.DEBUG, _PKG_NAME, path_to_scan)
8180

8281
if path_to_scan == "":
8382
if _windows:

tests/cli_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def main():
2323
fosslight_report_name = "test_result_func_call/result"
2424
output_dir = os.path.dirname(os.path.abspath(output_file_name))
2525

26-
logger = init_log(os.path.join(output_dir, "fosslight_src_log_"+start_time+".txt"))
26+
logger, result_item = init_log(os.path.join(output_dir, "fosslight_src_log_"+start_time+".txt"))
2727

2828
ret = run_scan(path_to_find_bin, fosslight_report_name, True, -1, True)
2929

tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ commands =
2424
cat test_scan/scan_result.csv
2525
fosslight_convert -p tests/json_result/scan_has_error.json -o test_convert/convert_result2
2626
fosslight_convert -p test_scan/scan_result.json -o test_convert/convert_result
27-
cat test_convert/convert_result.csv
27+
cat test_convert/convert_result_SRC.csv
2828
python tests/cli_test.py
2929

3030
[testenv:release]
@@ -35,9 +35,9 @@ commands =
3535
fosslight_source -h
3636
fosslight_convert -h
3737
fosslight_source -p tests/test_files -j -o test_scan/scan_result
38-
cat test_scan/scan_result.csv
38+
cat test_scan/scan_result_SRC.csv
3939
fosslight_convert -p tests/json_result/scan_has_error.json -o test_convert/convert_result2
4040
fosslight_convert -p test_scan/scan_result.json -o test_convert/convert_result
41-
cat test_convert/convert_result.csv
41+
cat test_convert/convert_result_SRC.csv
4242
python tests/cli_test.py
4343
pytest -v --flake8

0 commit comments

Comments
 (0)