Add log rotation to server & UI improvements #157

Merged
schmelczer merged 6 commits from asch/logs into main 2025-11-02 17:52:05 +00:00
schmelczer commented 2025-11-02 17:41:49 +00:00 (Migrated from github.com)
No description provided.
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2025-11-02 17:43:39 +00:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull Request Overview

This PR adds log rotation functionality to the server and includes several UI improvements. The main additions include a new RotatingFileWriter module that handles time-based log file rotation, configuration options for logging, and frontend enhancements for better timestamp handling and UI rendering.

Key Changes

  • Implemented a RotatingFileWriter for time-based log file rotation with support for configurable rotation intervals
  • Added logging configuration (LoggingConfig) to allow customization of log directory and rotation duration
  • Enhanced frontend sync history to display accurate timestamps from server responses instead of client-side timestamps
  • Improved UI rendering in the history view and file explorer cursor display

Reviewed Changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sync-server/src/utils/rotating_file_writer.rs New module implementing rotating file writer with time-based rotation and comprehensive test coverage
sync-server/src/utils.rs Added rotating_file_writer module export
sync-server/src/server.rs Updated create_server to accept Config directly instead of OsString path
sync-server/src/main.rs Refactored to load config early and set up dual logging (stdout and file with rotation)
sync-server/src/errors.rs Enhanced error display to include error type in formatted output
sync-server/src/consts.rs Added default constants for log directory and rotation interval
sync-server/src/config/logging_config.rs New logging configuration structure with defaults
sync-server/src/config.rs Added logging field to Config struct
sync-server/src/app_state.rs Simplified to accept Config directly instead of path
sync-server/config-e2e.yml Added logging configuration example
sync-server/Cargo.toml Added humantime-serde dependency for duration parsing
frontend/sync-client/src/tracing/sync-history.ts Made timestamp optional and use provided timestamp if available
frontend/sync-client/src/sync-operations/unrestricted-syncer.ts Added server timestamps to sync history entries
frontend/obsidian-plugin/src/views/history/history-view.scss Changed word-break from break-all to break-word for better readability
frontend/obsidian-plugin/src/views/cursors/file-explorer.ts Fixed cursor display logic to use startsWith for directory matching

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

## Pull Request Overview This PR adds log rotation functionality to the server and includes several UI improvements. The main additions include a new `RotatingFileWriter` module that handles time-based log file rotation, configuration options for logging, and frontend enhancements for better timestamp handling and UI rendering. ### Key Changes - Implemented a `RotatingFileWriter` for time-based log file rotation with support for configurable rotation intervals - Added logging configuration (`LoggingConfig`) to allow customization of log directory and rotation duration - Enhanced frontend sync history to display accurate timestamps from server responses instead of client-side timestamps - Improved UI rendering in the history view and file explorer cursor display ### Reviewed Changes Copilot reviewed 15 out of 16 changed files in this pull request and generated 3 comments. <details> <summary>Show a summary per file</summary> | File | Description | | ---- | ----------- | | sync-server/src/utils/rotating_file_writer.rs | New module implementing rotating file writer with time-based rotation and comprehensive test coverage | | sync-server/src/utils.rs | Added rotating_file_writer module export | | sync-server/src/server.rs | Updated create_server to accept Config directly instead of OsString path | | sync-server/src/main.rs | Refactored to load config early and set up dual logging (stdout and file with rotation) | | sync-server/src/errors.rs | Enhanced error display to include error type in formatted output | | sync-server/src/consts.rs | Added default constants for log directory and rotation interval | | sync-server/src/config/logging_config.rs | New logging configuration structure with defaults | | sync-server/src/config.rs | Added logging field to Config struct | | sync-server/src/app_state.rs | Simplified to accept Config directly instead of path | | sync-server/config-e2e.yml | Added logging configuration example | | sync-server/Cargo.toml | Added humantime-serde dependency for duration parsing | | frontend/sync-client/src/tracing/sync-history.ts | Made timestamp optional and use provided timestamp if available | | frontend/sync-client/src/sync-operations/unrestricted-syncer.ts | Added server timestamps to sync history entries | | frontend/obsidian-plugin/src/views/history/history-view.scss | Changed word-break from break-all to break-word for better readability | | frontend/obsidian-plugin/src/views/cursors/file-explorer.ts | Fixed cursor display logic to use startsWith for directory matching | </details> --- 💡 <a href="/schmelczer/vault-link/new/main/.github/instructions?filename=*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
@ -4,6 +4,7 @@
background-color: var(--color-base-00);
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-11-02 17:43:39 +00:00

Inconsistent indentation: this line uses spaces while the rest of the file uses tabs. Change to tab indentation to match the file's style.

	word-break: break-word;
Inconsistent indentation: this line uses spaces while the rest of the file uses tabs. Change to tab indentation to match the file's style. ```suggestion word-break: break-word; ```
@ -13,1 +13,4 @@
pub const DEFAULT_MAX_CLIENTS_PER_VAULT: usize = 256;
pub const DEFAULT_LOG_DIRECTORY: &str = "logs";
pub const DEFAULT_LOG_ROTATION_INTERVAL: Duration = Duration::from_secs(60 * 60 * 24); // 1 day
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-11-02 17:43:39 +00:00

The Duration import is missing from this file. Add use std::time::Duration; at the top of the file to make this constant compile.

The Duration import is missing from this file. Add `use std::time::Duration;` at the top of the file to make this constant compile.
@ -0,0 +84,4 @@
) -> SystemTime {
Self::find_latest_log_file(directory, file_prefix)
.and_then(|filename| Self::parse_log_timestamp(&filename, file_prefix))
.map_or_else(SystemTime::now, |last_rotation| {
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-11-02 17:43:39 +00:00

The calculate_next_rotation_time function always returns the current time when no log files exist, but the function should return the next rotation time (current time + rotation_duration) to be consistent with its name and behavior. When a writer is created for the first time, the next rotation should be scheduled for rotation_duration in the future, not immediately.

            .map_or_else(|| SystemTime::now() + rotation_duration, |last_rotation| {
The `calculate_next_rotation_time` function always returns the current time when no log files exist, but the function should return the *next* rotation time (current time + rotation_duration) to be consistent with its name and behavior. When a writer is created for the first time, the next rotation should be scheduled for rotation_duration in the future, not immediately. ```suggestion .map_or_else(|| SystemTime::now() + rotation_duration, |last_rotation| { ```
Sign in to join this conversation.
No description provided.