wony617
commited on
Commit
Β·
5d333b9
1
Parent(s):
ce8a422
Fix log function
Browse files- agent/workflow.py +16 -4
agent/workflow.py
CHANGED
@@ -217,23 +217,35 @@ def generate_github_pr(
|
|
217 |
if result["status"] == "success":
|
218 |
# Log successful PR to file
|
219 |
import datetime
|
220 |
-
|
|
|
221 |
try:
|
222 |
with open("pr_success.log", "a", encoding="utf-8") as f:
|
223 |
f.write(log_entry)
|
224 |
-
print(f"β
Logged
|
225 |
except Exception as e:
|
226 |
-
print(f"β Failed to log PR
|
227 |
|
228 |
return f"""β
**GitHub PR Creation Successful!**
|
229 |
|
230 |
-
π **PR URL:** {result
|
231 |
πΏ **Branch:** {result["branch"]}
|
232 |
π **File:** {result["file_path"]}{toctree_status}
|
233 |
|
234 |
{result["message"]}"""
|
235 |
|
236 |
elif result["status"] == "partial_success":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
return f"""β οΈ **Partial Success**
|
238 |
|
239 |
πΏ **Branch:** {result["branch"]}
|
|
|
217 |
if result["status"] == "success":
|
218 |
# Log successful PR to file
|
219 |
import datetime
|
220 |
+
pr_url = result.get('pr_url', 'NO_PR_URL')
|
221 |
+
log_entry = f"[{datetime.datetime.now().isoformat()}] {result['file_path']} -> {pr_url} ({result['status']})\n"
|
222 |
try:
|
223 |
with open("pr_success.log", "a", encoding="utf-8") as f:
|
224 |
f.write(log_entry)
|
225 |
+
print(f"β
Logged PR result: {log_entry.strip()}")
|
226 |
except Exception as e:
|
227 |
+
print(f"β Failed to log PR result: {e}")
|
228 |
|
229 |
return f"""β
**GitHub PR Creation Successful!**
|
230 |
|
231 |
+
π **PR URL:** {result.get('pr_url', 'NO_PR_URL')}
|
232 |
πΏ **Branch:** {result["branch"]}
|
233 |
π **File:** {result["file_path"]}{toctree_status}
|
234 |
|
235 |
{result["message"]}"""
|
236 |
|
237 |
elif result["status"] == "partial_success":
|
238 |
+
# Log partial success to file
|
239 |
+
import datetime
|
240 |
+
pr_url = result.get('pr_url', 'NO_PR_URL')
|
241 |
+
log_entry = f"[{datetime.datetime.now().isoformat()}] {result['file_path']} -> {pr_url} ({result['status']})\n"
|
242 |
+
try:
|
243 |
+
with open("pr_success.log", "a", encoding="utf-8") as f:
|
244 |
+
f.write(log_entry)
|
245 |
+
print(f"β
Logged PR result: {log_entry.strip()}")
|
246 |
+
except Exception as e:
|
247 |
+
print(f"β Failed to log PR result: {e}")
|
248 |
+
|
249 |
return f"""β οΈ **Partial Success**
|
250 |
|
251 |
πΏ **Branch:** {result["branch"]}
|