Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scripts/install.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GAIA Installer for Windows
# GAIA Installer for Windows
# One-command installation: irm https://amd-gaia.ai/install.ps1 | iex

$ErrorActionPreference = "Stop"
Expand Down
26 changes: 22 additions & 4 deletions src/gaia/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,15 @@ def configure_console_encoding():


class GaiaLogger:
def __init__(self, log_file="gaia.log"):
def __init__(self, log_file=None):
# Configure console encoding for Unicode support first
configure_console_encoding()

# Default to user's .gaia directory (not current working directory)
if log_file is None:
log_file = Path.home() / ".gaia" / "gaia.log"
log_file.parent.mkdir(parents=True, exist_ok=True)

self.log_file = Path(log_file)
self.loggers = {}

Expand Down Expand Up @@ -86,9 +91,22 @@ def __init__(self, log_file="gaia.log"):
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setFormatter(console_formatter)

# Configure file handler with UTF-8 encoding
file_handler = logging.FileHandler(self.log_file, encoding="utf-8")
file_handler.setFormatter(file_formatter)
# Configure file handler with UTF-8 encoding and error handling
try:
file_handler = logging.FileHandler(self.log_file, encoding="utf-8")
file_handler.setFormatter(file_formatter)
except PermissionError:
# Fallback to user's home directory if current dir is not writable
fallback_log = Path.home() / ".gaia" / "gaia.log"
fallback_log.parent.mkdir(parents=True, exist_ok=True)

print(f"⚠️ Cannot write to {self.log_file} (permission denied)", file=sys.stderr)
print(f" Writing logs to: {fallback_log}", file=sys.stderr)
print(f" Tip: Run commands from your home directory to avoid this warning\n", file=sys.stderr)

file_handler = logging.FileHandler(fallback_log, encoding="utf-8")
file_handler.setFormatter(file_formatter)
self.log_file = str(fallback_log) # Update log_file path

# Configure root logger
root_logger = logging.getLogger()
Expand Down
Loading