mirror of
https://github.com/j93es/browser-use-oauth.git
synced 2026-06-04 03:41:52 +09:00
- Removed old llm_login and session scripts, replacing them with a new structure for handling SSO login and session management. - Introduced a new prompt system for collecting SSO redirect URLs, ensuring compliance with security protocols. - Implemented a robust backend notification system for tracking scan initiation. - Enhanced browser profile configuration and resource management for improved session handling. - Added utility functions for environment variable checks and logging. - Updated the overall architecture to improve maintainability and readability.
29 lines
No EOL
947 B
Python
29 lines
No EOL
947 B
Python
from pathlib import Path
|
|
from datetime import datetime
|
|
|
|
# 미리 정해진 파일 경로
|
|
FILE_PATH = Path("data/log.txt")
|
|
|
|
def logger(msg: str) -> None:
|
|
try:
|
|
"""
|
|
msg 문자열을 파일 끝에 추가합니다.
|
|
- 파일이 없으면 새로 생성
|
|
- 디렉터리가 없으면 생성
|
|
"""
|
|
# 상위 디렉터리 생성 (이미 있으면 무시)
|
|
FILE_PATH.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
# 현재 시각 구해서 포맷팅
|
|
now = datetime.now()
|
|
timestamp = now.strftime("%Y-%m-%d %H:%M:%S")
|
|
|
|
# 메시지에 개행이 없으면 자동으로 붙이기
|
|
newline = "" if msg.endswith("\n") else "\n"
|
|
line = f"[{timestamp}] {msg}{newline}"
|
|
|
|
# 'a' 모드: 파일이 없으면 생성, 있으면 이어쓰기
|
|
with FILE_PATH.open(mode="a", encoding="utf-8") as f:
|
|
f.write(line)
|
|
except:
|
|
print(msg) |