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

[MOD] Split logs by day at midnight #62

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions vnpy_evo/trader/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ def __init__(self, main_engine: MainEngine, event_engine: EventEngine) -> None:
logger.remove() # Remove default stderr output

if SETTINGS["log.file"]:
today_date: str = datetime.now().strftime("%Y%m%d")
filename: str = f"vt_{today_date}.log"
log_path: Path = get_folder_path("log")
file_path: Path = log_path.joinpath(filename)
filename_pattern: str = log_path.joinpath("vt_{time:YYYYMMDD}.log") # Use {time} in filename

logger.add(
sink=file_path,
sink=filename_pattern,
level=self.level,
retention="4 weeks"
format=self.format,
rotation="00:00", # Rotate log file at midnight
retention="4 weeks" # Keep logs for 4 weeks
)

self.register_event()
Expand Down