Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to log console output when running headless #1415

Closed
SpcCw opened this issue Dec 14, 2023 · 2 comments
Closed

Option to log console output when running headless #1415

SpcCw opened this issue Dec 14, 2023 · 2 comments

Comments

@SpcCw
Copy link

SpcCw commented Dec 14, 2023

I run Fooocus on another Windows machine with --listen option so I can use it remotely and I set it to automatically launch on startup in scheduler task. It works just great except I can't figure out how to capture console output to some log file so if it crashes or something weird happens it can be reviewed.

Usual redirect like command > file.log results in empty file.

It would be great to have an optional argument like --log file.log which would then write all console messages to it so it could be viewed remotely for diagnostics.

@mashb1t
Copy link
Collaborator

mashb1t commented Dec 14, 2023

A workaround would be to use docker compose with the file log driver.
Dockerfile: see #1154

@mashb1t
Copy link
Collaborator

mashb1t commented Dec 29, 2023

@SpcCw The secret to make it work is to either flush Python buffer or not use any.
-u does the trick here to disable the buffer altogether:
.\python_embeded\python.exe -u -s Fooocus\entry_with_update.py

This may cause potential issues though. See https://www.baeldung.com/linux/python-buffering-and-tee

You can also use PowerShell with Tee-Object in combination with -u. Tested and it's working with .\python_embeded\python.exe -u -s Fooocus\entry_with_update.py -- listen | Tee-Object -FilePath "output.log"
See https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/tee-object?view=powershell-7.4#example-1-output-processes-to-a-file-and-to-the-console

@mashb1t mashb1t closed this as completed Dec 29, 2023
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

No branches or pull requests

2 participants