Skip to content

Commit dcf8e3d

Browse files
Redirect SCANOSS output to log file
Signed-off-by: Wonjae Park <[email protected]>
1 parent 9eaca66 commit dcf8e3d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/fosslight_source/run_scanoss.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import shutil
1818
from pathlib import Path
1919
from scanoss.scanner import Scanner, ScanType
20+
import io
21+
import contextlib
2022

2123
logger = logging.getLogger(constant.LOGGER_NAME)
2224
warnings.filterwarnings("ignore", category=FutureWarning)
@@ -75,7 +77,14 @@ def run_scanoss_py(path_to_scan: str, output_file_name: str = "", format: list =
7577
scan_options=ScanType.SCAN_SNIPPETS.value,
7678
nb_threads=num_threads if num_threads > 0 else 10
7779
)
78-
scanner.scan_folder_with_options(scan_dir=path_to_scan)
80+
81+
output_buffer = io.StringIO()
82+
with contextlib.redirect_stdout(output_buffer), contextlib.redirect_stderr(output_buffer):
83+
scanner.scan_folder_with_options(scan_dir=path_to_scan)
84+
captured_output = output_buffer.getvalue()
85+
logger.info(f"|---Scanning With SCANOSS Start---|")
86+
logger.info(f"{captured_output}")
87+
logger.info(f"|---Scanning With SCANOSS Finished---|")
7988

8089
if os.path.isfile(output_json_file):
8190
total_files_to_excluded = []

0 commit comments

Comments
 (0)