Skip to content

Log view#22

Merged
meesoft merged 5 commits intomainfrom
features/LogView
Mar 23, 2025
Merged

Log view#22
meesoft merged 5 commits intomainfrom
features/LogView

Conversation

@meesoft
Copy link
Owner

@meesoft meesoft commented Mar 22, 2025

Summary by CodeRabbit

  • New Features

    • Added a toggleable log view, accessible via Ctrl+F12, that displays dynamic system logs and history in real-time, enabling easier monitoring of events.
    • Introduced a video speedup option with adjustable settings and a refined user interface, providing more flexible and intuitive control over video processing.
    • Updated interface layouts improve control placements and responsiveness, enhancing the overall user experience.
    • Implemented a new logging mechanism that captures and displays log entries throughout the application.
  • Bug Fixes

    • Enhanced error handling by integrating a dedicated logging utility for better tracking of exceptions.
  • Chores

    • Removed unnecessary dependencies and streamlined code for improved maintainability.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 22, 2025

Walkthrough

This pull request overhauls the logging mechanism across the codebase. It replaces numerous Debug.WriteLine calls with a new custom Log class that provides structured logging with history and events. Additionally, the UI now supports toggling a log view via a new command and key binding, with adjustments to layouts and view properties. Minor updates include reordering of using directives, renaming constants, and enhanced error handling in several modules, alongside improved video transformation controls.

Changes

File(s) Change Summary
PhotoLocator/Helpers/ExceptionHandler.cs Updated logging in ShowException and LogException to use Log.Write instead of Debug.WriteLine; removed unnecessary System.Diagnostics directive.
PhotoLocator/Helpers/Log.cs Introduced a new static Log class with overloaded Write methods, an event (EventAdded), and a method to retrieve log history.
PhotoLocator/MainViewModel.cs, PhotoLocator/MainWindow.xaml, PhotoLocator/MainWindow.xaml.cs Added log view toggling functionality with a new LogViewHeight property, ToggleLogCommand, key binding (Ctrl+F12), new UI elements (GridSplitter, LogTextBox), and dynamic log updates via subscription to Log.EventAdded.
PhotoLocator/MapDisplay/HyperlinkText.cs, PhotoLocator/PictureFileFormats/GeneralFileFormatHandler.cs, PhotoLocator/PictureFileFormats/JpegliEncoder.cs, PhotoLocator/PictureFileFormats/VideoFileFormatHandler.cs, PhotoLocator/PictureItemViewModel.cs, PhotoLocator/VideoTransformCommands.cs Replaced Debug.WriteLine calls with Log.Write; adjusted using directives, renamed constants (e.g., InputFileName to InputListFileName), and added new properties (IsSpeedupChecked, SpeedupBy) for video processing enhancements.
PhotoLocator/VideoTransformWindow.xaml Refactored layout from StackPanel to DockPanel for video transform controls; added new UI elements for speedup functionality and adjusted margins and alignments.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MainWindow
    participant MainViewModel
    participant Log
    User->>MainWindow: Press Ctrl+F12 (Toggle Log)
    MainWindow->>MainViewModel: Execute ToggleLogCommand
    MainViewModel->>MainWindow: Update LogViewHeight
    MainWindow->>Log: Check log view state
    alt Log view active
        Log-->>MainWindow: Return log history (via GetHistory)
        Log-->>MainWindow: Trigger EventAdded on new log entry
        MainWindow->>MainWindow: Append log to LogTextBox
    else Log view inactive
        MainWindow->>Log: Unsubscribe from Log.EventAdded
        MainWindow->>MainWindow: Clear LogTextBox
    end
Loading
sequenceDiagram
    participant User
    participant VideoTransformCommands
    participant Process
    participant Log
    User->>VideoTransformCommands: Initiate video transformation
    VideoTransformCommands->>VideoTransformCommands: Check IsSpeedupChecked & SpeedupBy
    VideoTransformCommands->>Process: Start process with updated arguments (using InputListFileName, speedup filter)
    Process-->>VideoTransformCommands: Return process output/errors
    VideoTransformCommands->>Log: Log process output via Log.Write
Loading

Possibly related PRs

  • jpegli writer #9: The changes in the main PR, specifically the logging modifications in the ExceptionHandler class, are related to the changes in the retrieved PR, which also involve logging updates in the GeneralFileFormatHandler and JpegliEncoder classes, as they all transition from using Debug.WriteLine to a unified logging approach with the Log class.
  • Pass streams to jpegli #17: The changes in the main PR, specifically the logging modifications in the ExceptionHandler class, are related to the changes in the retrieved PR, which also involve logging updates in the JpegliEncoder class, as both PRs replace Debug.WriteLine calls with Log.Write calls for logging purposes.
  • Adjust EXIF timestamps dialog #13: The changes in the main PR, which involve updating logging methods in the ExceptionHandler class to use a new Log class, are related to the changes in the retrieved PR, where similar updates to logging methods are made in various classes, including PictureItemViewModel and VideoTransformCommands, indicating a consistent shift towards a unified logging approach.

Poem

I'm a bunny in the code, with hops so light,
Leaving Debug trails for Log to shine bright.
With toggles and keys, my log view is new,
Each log entry dances as updates ensue.
In CodeRabbit’s realm, every change is a treat,
Hopping through code with a joyful beat! 🐇


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f811a14 and 1777a85.

📒 Files selected for processing (2)
  • PhotoLocator/Metadata/ExifHandler.cs (3 hunks)
  • PhotoLocator/Metadata/Rational.cs (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • PhotoLocator/Metadata/Rational.cs
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Analyze (csharp)
  • GitHub Check: build
🔇 Additional comments (1)
PhotoLocator/Metadata/ExifHandler.cs (1)

94-94: Property renaming consistently applied across the codebase

The change from abbreviated property names (Num, Denom) to more descriptive ones (Numerator, Denominator) improves code readability and follows better naming conventions. The changes have been consistently applied throughout the file.

Also applies to: 514-515, 565-566, 572-572, 576-576

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
PhotoLocator/Metadata/Rational.cs (1)

79-79: Inconsistent property pattern

While other fields have been converted to auto-properties, the Bytes field remains a public readonly field. Consider converting this field to follow the same pattern for consistency.

- public readonly long[] Bytes;
+ public long[] Bytes { get; }
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 16c978f and e2acd97.

📒 Files selected for processing (9)
  • .editorconfig (2 hunks)
  • PhotoLocator/BitmapOperations/AverageFramesOperation.cs (1 hunks)
  • PhotoLocator/BitmapOperations/MaxFramesOperation.cs (1 hunks)
  • PhotoLocator/Gps/GpsTrace.cs (1 hunks)
  • PhotoLocator/Helpers/SelectorComparer.cs (0 hunks)
  • PhotoLocator/Helpers/Vector2.cs (1 hunks)
  • PhotoLocator/MainWindow.xaml.cs (5 hunks)
  • PhotoLocator/Metadata/Rational.cs (3 hunks)
  • PhotoLocator/PictureFileFormats/VideoFileFormatHandler.cs (1 hunks)
💤 Files with no reviewable changes (1)
  • PhotoLocator/Helpers/SelectorComparer.cs
🚧 Files skipped from review as they are similar to previous changes (1)
  • PhotoLocator/PictureFileFormats/VideoFileFormatHandler.cs
🧰 Additional context used
🧬 Code Definitions (3)
PhotoLocator/BitmapOperations/AverageFramesOperation.cs (1)
PhotoLocator/BitmapOperations/CombineFramesOperationBase.cs (2) (2)
  • CombineFramesOperationBase (11-156)
  • CombineFramesOperationBase (32-43)
PhotoLocator/BitmapOperations/MaxFramesOperation.cs (1)
PhotoLocator/BitmapOperations/CombineFramesOperationBase.cs (2) (2)
  • CombineFramesOperationBase (11-156)
  • CombineFramesOperationBase (32-43)
PhotoLocator/MainWindow.xaml.cs (1)
PhotoLocator/Helpers/Log.cs (1) (1)
  • Log (7-37)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Analyze (csharp)
  • GitHub Check: build
  • GitHub Check: build
🔇 Additional comments (16)
PhotoLocator/BitmapOperations/MaxFramesOperation.cs (1)

8-8: Cleanup: Removed redundant IDisposable interface.

This change correctly removes the redundant IDisposable interface declaration from the class. Since the base class CombineFramesOperationBase already implements IDisposable (as seen in the relevant code snippets), the derived class automatically inherits this implementation. No functionality is lost, and the code is now cleaner.

PhotoLocator/BitmapOperations/AverageFramesOperation.cs (1)

8-8: Cleanup: Removed redundant IDisposable interface.

This change correctly removes the redundant IDisposable interface declaration from the class. Since the base class CombineFramesOperationBase already implements IDisposable (as seen in the relevant code snippets), the derived class automatically inherits this implementation. No functionality is lost, and the code is now cleaner.

PhotoLocator/Gps/GpsTrace.cs (1)

14-14: Good property modernization.

This change improves the code by converting a readonly field to a property with a getter, which follows better encapsulation practices. The new collection initializer syntax ([]) is also more concise than the previous new List<DateTime>(). Both implementations maintain the same behavior - preventing reassignment of the list reference while allowing modifications to the list contents.

PhotoLocator/Helpers/Vector2.cs (1)

51-68: Improved control flow in Angle() method.

The restructuring of the Angle() method maintains its mathematical correctness while making the code more readable with a more linear flow. The method now handles all quadrants correctly:

  • When X > 0: First quadrant (Y ≥ 0) and fourth quadrant (Y < 0)
  • When X < 0: Second quadrant (Y ≥ 0) and third quadrant (Y < 0)
  • When X = 0: Special cases where the angle is exactly ±π/2

This refactoring preserves the documented behavior of returning angles in the range [-π, π].

.editorconfig (2)

17-19: Appropriate suppression of IDE0305 rule.

The new setting disables warnings for collection initialization style, which is beneficial for maintaining code consistency when working with collections throughout the logging overhaul.


185-185: Consistent style configuration for events.

This style setting ensures events don't require qualification, which aligns with the existing settings for properties, methods, and fields. Consistency in style improves readability across the codebase.

PhotoLocator/MainWindow.xaml.cs (6)

7-7: System.Diagnostics import added to support logging.

This import is necessary for integrating with the Debug class. Consistent with the PR's objective of overhauling logging mechanisms.


32-32: Good addition of _isLogActive field.

This field appropriately tracks the active state of the log view and follows the existing pattern of boolean flags in the class.


92-92: Appropriate event registration for log view updates.

The event handler efficiently uses a lambda to call UpdateLogView when the LogTextBox size changes, which is the right approach for managing log visibility.


339-356: Well-implemented log view management logic.

The UpdateLogView method efficiently:

  • Avoids unnecessary work with an early return if the state hasn't changed
  • Properly populates log history when activated
  • Correctly subscribes/unsubscribes from Log.EventAdded event
  • Ensures smooth user experience with scrolling to the end of the log

The threshold check (ActualHeight > 4) is a practical way to determine visibility.


358-365: Proper UI thread handling for log events.

The method correctly:

  • Uses Dispatcher.BeginInvoke to safely update UI from a potentially different thread
  • Appends new log lines with appropriate formatting
  • Ensures the latest logs are visible by scrolling to the end

This implementation properly handles the asynchronous nature of logging events.


525-525: Good event cleanup in Dispose method.

Unsubscribing from the Log.EventAdded event in the Dispose method prevents potential memory leaks, following proper resource cleanup practices.

PhotoLocator/Metadata/Rational.cs (4)

11-13: Property encapsulation improvement

Converting public fields to auto-properties with getters improves encapsulation while maintaining the same immutable behavior. This change aligns with C# best practices and makes the code more maintainable.


22-22: Modern C# syntax improvement

The change from bytes.Slice(4) to the range operator bytes[4..] is a good modernization that makes the code more concise while maintaining the same functionality.


76-78: Property encapsulation improvement

Converting public readonly fields to auto-properties with getters in the GPSRational class follows the same good practice as in the Rational class.


80-80:

Details

✅ Verification successful

Behavior change: AngleInDegrees is now mutable

This change makes AngleInDegrees mutable by adding a setter, which is a behavior change. Ensure this doesn't break any code that relies on this property being immutable after construction.


🏁 Script executed:

#!/bin/bash
# Check if AngleInDegrees is modified anywhere in the codebase
rg "\.AngleInDegrees\s*=" --type csharp

Length of output: 369


Verified: AngleInDegrees Mutability Is Being Utilized Intentionally

The grep output confirms that the setter is actively used in PhotoLocator/Metadata/ExifHandler.cs (e.g., negating the latitude and longitude values). Since the property is modified in this context, ensure that all consumers of AngleInDegrees are reviewed to confirm that this change was intentional and does not inadvertently break any logic assuming immutability.

  • Action Required: Double-check any code sections or associated tests that might have been written under the assumption of immutability.

@sonarqubecloud
Copy link

@meesoft meesoft merged commit 4b4aa6f into main Mar 23, 2025
6 checks passed
@meesoft meesoft deleted the features/LogView branch March 23, 2025 09:12
@coderabbitai coderabbitai bot mentioned this pull request Aug 22, 2025
@coderabbitai coderabbitai bot mentioned this pull request Feb 16, 2026
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.

1 participant