diff --git a/src/app.py b/src/app.py index 489f4a7..9dad99c 100644 --- a/src/app.py +++ b/src/app.py @@ -49,8 +49,18 @@ def get_logs(): if issue_type not in config: return jsonify({"error": "Invalid issue type"}) issue_config = config[issue_type] - response = {log.get('log_file').split('*')[0]: read_log_from_dir(*split_directory_and_file(log.get('log_file')), log['lines']) if '*' in log.get('log_file') else read_log(log['log_file'], log['lines']) for log in issue_config['logs']} - response.update({comm.get('tag'): os.popen(comm.get('comm')).read() for comm in issue_config['commands']}) + # response = {log.get('log_file').split('*')[0]: read_log_from_dir(*split_directory_and_file(log.get('log_file')), log['lines']) if '*' in log.get('log_file') else read_log(log['log_file'], log['lines']) for log in issue_config['logs']} + # response.update({comm.get('tag'): os.popen(comm.get('comm')).read() for comm in issue_config['commands']}) + + response = { + log.get('log_file').split('*')[0]: f"```\n{read_log_from_dir(*split_directory_and_file(log.get('log_file')), log['lines'])}\n```" if '*' in log.get('log_file') else f"```\n{read_log(log['log_file'], log['lines'])}\n```" + for log in issue_config['logs'] + } + response.update({ + comm.get('tag'): f"```\n{os.popen(comm.get('comm')).read()}\n```" for comm in issue_config['commands'] + }) + + except Exception as e: return jsonify({"error": str(e)}) return jsonify(response)