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

Add features: company blacklist supports wildcard; Archive and cleanup ./log/app.log if larger than 100MB. #607

Closed
wants to merge 10 commits into from

Conversation

BlackHoleExelion
Copy link
Contributor

@BlackHoleExelion BlackHoleExelion commented Oct 25, 2024

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.

@surapuramakhil
Copy link
Contributor

@BlackHoleExelion can you add log rotation instead of clean up?

@BlackHoleExelion
Copy link
Contributor Author

@BlackHoleExelion can you add log rotation instead of clean up?

Sure. Updated.

@BlackHoleExelion BlackHoleExelion changed the title Add features: company blacklist supports wildcard; Check and cleanup log if larger than 100MB Add features: company blacklist supports wildcard; Archive and cleanup ./log/app.log if larger than 100MB. Oct 27, 2024
@surapuramakhil surapuramakhil self-requested a review October 27, 2024 02:25
@@ -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():
Copy link
Contributor

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()

Copy link
Contributor

@surapuramakhil surapuramakhil left a 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.

@surapuramakhil surapuramakhil changed the base branch from main to release/v11.01.2024 October 27, 2024 03:10
@surapuramakhil
Copy link
Contributor

@BlackHoleExelion this PR already handles logging issues. check it feel free to add additional logging configs if necessary.
#598

kindly clean up (remove this from code) this method def cleanup_log_file():

@BlackHoleExelion BlackHoleExelion closed this by deleting the head repository Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants