-
Notifications
You must be signed in to change notification settings - Fork 963
Add log rotation #312
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
base: main
Are you sure you want to change the base?
Add log rotation #312
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary of Changes
Hello @qinantong, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
I've implemented log rotation for the application's logging system. This change addresses the issue of potentially excessively large log files by automatically managing their size and number of backups. It provides configurable options for log file size and backup count, ensuring more efficient disk space usage and easier log management without manual intervention.
Highlights
- Log Rotation Implementation: I've introduced log rotation for the application's log files. This prevents log files from growing indefinitely large, which can consume excessive disk space and make log analysis difficult. The system will now automatically manage log file sizes.
- Configurable Log Rotation Parameters: Users can now configure the maximum size of a log file and the number of backup log files to keep using the
LOG_MAX_SIZE
andLOG_BACKUP_COUNT
environment variables. The default maximum size is 10MB, and the default number of backup files is 5. This provides flexibility for different deployment environments. - Integration with
setup_logging
: Thesetup_logging
function inapi/logging_config.py
has been updated to incorporate theRotatingFileHandler
. This change ensures that log files are automatically rotated when they reach the specified size, creating new log files and managing old ones.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command>
or @gemini-code-assist <command>
. Below is a summary of the supported commands.
Feature | Command | Description |
---|---|---|
Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/
folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces log rotation, which is a great improvement. The implementation is mostly correct, but I've found a critical bug in how the log size is configured from environment variables, which makes the feature non-functional. I've also added a couple of suggestions to improve code clarity and documentation. Please address the critical issue before merging.
It has been found that there is no restriction on the size of log files in the system. Sometimes, excessively large log files may become a burden, so this PR is proposed. This PR modifies the logging_config.py file by adding log rotation. Similar to LOG_LEVEL, it supports configuring the maximum allowed log file size and the maximum number of log files to keep through LOG_MAX_SIZE and LOG_BACKUP_COUNT in the .env file. The default value of LOG_MAX_SIZE is 10MB, and the default value of LOG_BACKUP_COUNT is 5. The unit of LOG_MAX_SIZE is MB.