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
3 changes: 3 additions & 0 deletions src/uipath/runtime/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class UiPathRuntimeContext(BaseModel):
resume: bool = False
command: str | None = None
job_id: str | None = None
log_to_file: bool = False
conversation_id: str | None = Field(
None, description="Conversation identifier for CAS"
)
Expand Down Expand Up @@ -188,6 +189,7 @@ def __enter__(self):
dir=self.runtime_dir,
file=self.logs_file,
job_id=self.job_id,
log_to_file=self.log_to_file,
)
self.logs_interceptor.setup()

Expand Down Expand Up @@ -327,6 +329,7 @@ def with_defaults(

# Apply defaults from env
base.job_id = os.environ.get("UIPATH_JOB_KEY")
base.log_to_file = os.environ.get("UIPATH_LOG_TO_FILE", "").lower() == "true"
base.logs_min_level = os.environ.get("LOG_LEVEL", "INFO")
base.org_id = os.environ.get("UIPATH_ORGANIZATION_ID")
base.tenant_id = os.environ.get("UIPATH_TENANT_ID")
Expand Down
6 changes: 4 additions & 2 deletions src/uipath/runtime/logging/_interceptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __init__(
job_id: str | None = None,
execution_id: str | None = None,
log_handler: logging.Handler | None = None,
log_to_file: bool = False,
):
"""Initialize the log interceptor.

Expand All @@ -38,6 +39,7 @@ def __init__(
job_id (str, optional): If provided, logs go to file; otherwise, to stdout.
execution_id (str, optional): Unique identifier for this execution context.
log_handler (logging.Handler, optional): Custom log handler to use for this execution context.
log_to_file (bool): If True, force file logging even without a job_id.
"""
min_level = min_level or "INFO"
self.job_id = job_id
Expand Down Expand Up @@ -67,8 +69,8 @@ def __init__(
if log_handler:
self.log_handler = log_handler
else:
# Create either file handler (runtime) or stdout handler (debug)
if not job_id:
# Create either file handler (runtime/log_to_file) or stdout handler (debug)
if not job_id and not log_to_file:
# Only wrap if stdout is using a problematic encoding (like cp1252 on Windows)
if (
hasattr(sys.stdout, "encoding")
Expand Down
Loading