From bab03a332508b473936a7dc44550a6caeca2d952 Mon Sep 17 00:00:00 2001
From: "gioacchino.vino" <gioacchino.vino@infn.it>
Date: Fri, 29 Sep 2023 15:13:43 +0200
Subject: [PATCH] show scans logs

---
 files/script.py  | 3 ++-
 tasks/2-scan.yml | 8 ++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/files/script.py b/files/script.py
index a4b4993..76eebb9 100644
--- a/files/script.py
+++ b/files/script.py
@@ -43,6 +43,7 @@ def create_port_list(port_list_name, ports):
     status_text = res.xpath('@status_text')[0]
     if status == "201":
         id = res.xpath('@id')[0]
+        logging.debug(f'Created port list obj. Name: {port_list_name}, id: {id}, ports: {ports}')
         return {'name': port_list_name, 'id': id}
     else:
         logging.error(f"ERROR during Port list creation. Status code: {status}, msg: {status_text}")
@@ -423,7 +424,7 @@ def import_dep_info(file_path, endpoints_to_scan):
 ################ MAIN #######################################
 
 logging.basicConfig(
-    filename='debug.log', 
+    filename='scans.log', 
     level=logging.DEBUG,
     format='%(asctime)s %(levelname)-8s %(message)s',
     datefmt='%Y-%m-%d %H:%M:%S',
diff --git a/tasks/2-scan.yml b/tasks/2-scan.yml
index 2b59d72..4a51742 100644
--- a/tasks/2-scan.yml
+++ b/tasks/2-scan.yml
@@ -35,6 +35,14 @@
   with_items: "{{report_files.files}}"
   when: summary_report_json.global == 'NOK'
 
+- name: Load scans log
+  command: cat "{{ paas_ci_workdir + '/scans.log'}}"
+  register: scans_log
+
+- name: Show scans log
+  debug:
+    msg: "{{ scans_log.output }}"
+
 - name: Detailed report summary
   debug:
     var: summary_report_json
-- 
GitLab