Skip to content

fix(serve): enable file logging for HTTP API sessions via file_logconfig field - #331

Open
kun-codes wants to merge 2 commits into
mozarkai:mainfrom
kun-codes:fix/fix-optics-serve-logging
Open

fix(serve): enable file logging for HTTP API sessions via file_logconfig field#331
kun-codes wants to merge 2 commits into
mozarkai:mainfrom
kun-codes:fix/fix-optics-serve-logging

Conversation

@kun-codes

@kun-codes kun-codes commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Before this PR, no log files were being written to using optics serve.
After this PR, file logging can be enabled using "file_log": true, in request body for POST {{baseUrl}}/v1/sessions/start

@sonarqubecloud

sonarqubecloud Bot commented Jul 3, 2026

Copy link
Copy Markdown

@kun-codes
kun-codes marked this pull request as ready for review July 3, 2026 12:14
Copilot AI review requested due to automatic review settings July 3, 2026 12:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the FastAPI session-start endpoint configuration model so HTTP API callers can enable file-based logging per session via a new file_log boolean field.

Changes:

  • Add file_log: bool = False to the REST SessionConfig model.
  • Pass file_log into the internal Config used to create a session.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 436 to 440
project_path=config.project_path,
log_level=LOG_LEVEL_DEBUG
log_level=LOG_LEVEL_DEBUG,
file_log=file_log
)
templates = (
Comment on lines 257 to +260
appium_url: Optional[str] = None
appium_config: Optional[Dict[str, Any]] = None
api_data: Optional[Dict[str, Any]] = None # Inline API definitions only; file path not supported in REST
file_log: bool = False
@malto101

malto101 commented Jul 3, 2026

Copy link
Copy Markdown
Member

how to do you plan to fetch the file logs from containers?

@kun-codes

Copy link
Copy Markdown
Contributor Author

@malto101 How about using docker volume mounts to store the logs from the container on the host system? when file_log is set to true, they will get stored on the host system.

And when file logging isn't required, logs go to stderr which can be read through docker logs command

@malto101

malto101 commented Jul 6, 2026

Copy link
Copy Markdown
Member

@malto101 How about using docker volume mounts to store the logs from the container on the host system? when file_log is set to true, they will get stored on the host system.

And when file logging isn't required, logs go to stderr which can be read through docker logs command

That works, just double check if there's a export logs option in docker or other container services so we do not duplicate work

@kun-codes

Copy link
Copy Markdown
Contributor Author

@malto101 docker logs <container_name> > logs.txt 2>&1 can be used to export logs in docker. For podman the command is podman logs <container_name> > logs.txt 2>&1

@malto101

malto101 commented Jul 9, 2026

Copy link
Copy Markdown
Member

@malto101 docker logs <container_name> > logs.txt 2>&1 can be used to export logs in docker. For podman the command is podman logs <container_name> > logs.txt 2>&1

right,
if a soln existing, we can use it,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants