Created
March 25, 2024 21:49
-
-
Save iloveitaly/aa616d08d582c20e717ecd047b1c8534 to your computer and use it in GitHub Desktop.
funnel all the OpenAI logs to a specific file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setup(): | |
""" | |
Config below is subject to change | |
https://stackoverflow.com/questions/76256249/logging-in-the-open-ai-python-library/78214464#78214464 | |
https://github.com/openai/openai-python/blob/de7c0e2d9375d042a42e3db6c17e5af9a5701a99/src/openai/_utils/_logs.py#L16 | |
""" | |
openai_log_path = taxdocs.root / "openai.log" | |
openai_file_handler = logging.FileHandler(openai_log_path) | |
openai_logger = logging.getLogger("openai") | |
openai_logger.addHandler(openai_file_handler) | |
httpx_logger = logging.getLogger("httpx") | |
httpx_logger.addHandler(openai_file_handler) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment