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

Tee support #56

Open
minrk opened this issue Feb 2, 2022 · 1 comment
Open

Tee support #56

minrk opened this issue Feb 2, 2022 · 1 comment

Comments

@minrk
Copy link
Owner

minrk commented Feb 2, 2022

Sometimes when I capture output, I want to not just redirect it, but tee it (write to both the original and redirected files, instead of only the redirected file). This could probably be a simple flag, since we already have an internal handle on the original FD for restoring later.

@laf070810
Copy link

laf070810 commented Nov 16, 2024

Currently is there a way to tee to both console output and file output in jupyter notebook? In jupyter notebook, we have cell output, console output and file output. By doing like

from wurlitzer import pipes, STDOUT
import logging

logger = logging.getLogger()
logger.setLevel(logging.INFO)
logger.addHandler(logging.StreamHandler())
logger.addHandler(logging.FileHandler("mycode.log"))

with pipes(logger, stderr=STDOUT):
    call_some_c_function()

I can tee to cell output and file output. But I haven't found a way to tee to the console output and file output. Using like logger.addHandler(logging.StreamHandler(sys.__stdout__)) will cause infinite loop.

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