-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Add features: company blacklist supports wildcard; Archive and cleanup ./log/app.log if larger than 100MB. #607
Add features: company blacklist supports wildcard; Archive and cleanup ./log/app.log if larger than 100MB. #607
Conversation
@BlackHoleExelion can you add log rotation instead of clean up? |
Sure. Updated. |
@@ -191,11 +194,39 @@ def create_and_run_bot(parameters, llm_api_key): | |||
except Exception as e: | |||
raise RuntimeError(f"Error running the bot: {str(e)}") | |||
|
|||
def cleanup_log_file(): |
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.
Instead of doing this manually can you use logaru configs where we define our logger.
an example code
from loguru import logger
import sys
# Remove default logger
logger.remove()
# Add console output
logger.add(sys.stdout, format="{time} {level} {message}")
# Add file output with rotation
logger.add(
"app.log",
rotation="500 MB", # Rotate when file reaches 500MB
retention="10 days", # Keep logs for 10 days
compression="zip", # Compress rotated files
format="{time:YYYY-MM-DD HH:mm:ss} | {level} | {message}",
level="INFO"
)
# Example usage
def main():
while True:
logger.info("This is an info message")
logger.error("This is an error message")
logger.debug("This is a debug message")
if __name__ == "__main__":
main()
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.
@BlackHoleExelion log rotation, log clean are solved problem - use our existing logger for achieving it. we don't always need to reinvent the wheel.
@BlackHoleExelion this PR already handles logging issues. check it feel free to add additional logging configs if necessary. kindly clean up (remove this from code) this method def cleanup_log_file(): |
Add feature: company blacklist supports wildcard in config.yaml
Add feature: Archive and cleanup ./log/app.log if larger than 100MB. Archived log will be kept for 5 days. It runs at the very beginning of the code, so you may experience kinda lag.