Refactor Logging utility for thread safety #383
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request refactors the logging system throughout the
WhisperKitcodebase to use a new, actor-based, async-safe staticLoggingAPI. The update removes the singleton pattern, introduces async log level and callback management, and standardizes how log messages are dispatched. Additionally, it updates all existing usages to the new API and improves the clarity of some debug messages.Logging System Refactor:
Logging.sharedsingleton class with a static, actor-backedLoggingenum, making logging async-safe and thread-safe. The new design centralizes log level and callback management and uses Swift Concurrency for updates. (Sources/WhisperKit/Utilities/Logging.swift)Sources/WhisperKit/Core/WhisperKit.swift,Sources/WhisperKit/Core/TranscribeTask.swift,Tests/WhisperKitTests/UnitTests.swift)Debug Message Improvements:
.debugDescriptionfor progress and.localizedDescriptionfor errors. (Sources/WhisperKit/Core/WhisperKit.swift,Tests/WhisperKitTests/RegressionTests.swift)Code Clean-up and Modernization:
Sources/WhisperKit/Utilities/Logging.swift)These changes modernize the logging infrastructure, making it safer and more robust for concurrent and async contexts, and improve the consistency and clarity of log output across the codebase.