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

Allow customing log filename with date and time #44

Merged
merged 1 commit into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Allow customing log filename with date and time
  • Loading branch information
ChrisJefferson committed Jul 7, 2023
commit 4d4960345228b7952393b88e3ee97f0cf5bcf91e
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ optional arguments:
temperature defined for the assistant.
--top_p TOP_P The top_p to use for the chat session. Overrides the default top_p defined
for the assistant.
--log_file LOG_FILE The file to write logs to
--log_file LOG_FILE The file to write logs to. Supports strftime format codes.
--log_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
The log level to use
--prompt PROMPT, -p PROMPT
Expand Down
6 changes: 4 additions & 2 deletions gpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import argparse
import sys
import logging
import datetime
import google.generativeai as genai
import gptcli.anthropic
from gptcli.assistant import (
Expand Down Expand Up @@ -92,7 +93,7 @@ def parse_args(config: GptCliConfig):
"--log_file",
type=str,
default=config.log_file,
help="The file to write logs to",
help="The file to write logs to. Supports strftime format codes.",
)
parser.add_argument(
"--log_level",
Expand Down Expand Up @@ -150,8 +151,9 @@ def main():
args = parse_args(config)

if args.log_file is not None:
filename = datetime.datetime.now().strftime(args.log_file)
logging.basicConfig(
filename=args.log_file,
filename=filename,
level=args.log_level,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
)
Expand Down