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 autosave functionality to BasicLogger #13679

Closed
wants to merge 7 commits into from

Conversation

geezer09
Copy link

@geezer09 geezer09 commented Nov 7, 2024

This pull request introduces an autosave feature to the BasicLogger class in the Vassal application. The most important changes include the addition of a scheduled executor service to handle periodic autosaving, the implementation of the autosave logic, and modifications to the write method to support writing to a specified file. We simply append the word autosave_ to the current file we are logging to and then save to that file every 5 minutes.

Autosave Feature Implementation:

  • Added ScheduledExecutorService to BasicLogger for scheduling periodic tasks. [1] [2]
  • Implemented startAutosave method to schedule the autosave method at fixed intervals.
  • Added autosave method to handle the logic of saving the log file periodically.

Modifications to Writing Logic:

  • Modified write method to support writing to a specified file, used by the autosave feature.

Localization:

  • Added a new localization string for autosave log message in VASSAL.properties.

}

private void startAutosave() {
scheduler.scheduleAtFixedRate(this::autosave, 5, 5, TimeUnit.SECONDS);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Five seconds is probably too short.

There's nothing to debounce the autosave if autosaving takes longer than the autosave interval.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed that to start after a minute and save every 5 minutes.

@geezer09 geezer09 closed this Nov 11, 2024
@geezer09 geezer09 deleted the feature/log_autosave branch November 11, 2024 03:09
@geezer09 geezer09 mentioned this pull request Nov 11, 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.

2 participants