Skip to content

How to log what GPTR does to a file? #852

Answered by danieldekay
danieldekay asked this question in Q&A
Discussion options

You must be logged in to vote

Copilot suggested something easier:

        # Capture all logs generated while this line runs
        with open("researcher_log.txt", "w") as f:
            log_handler = logging.StreamHandler(f)
            log_handler.setLevel(logging.DEBUG)
            logger = logging.getLogger()
            logger.addHandler(log_handler)
            try:
                research_result = await researcher.conduct_research()
            finally:
                logger.removeHandler(log_handler)

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@ElishaKay
Comment options

@danieldekay
Comment options

Answer selected by danieldekay
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants