Skip to content

Conversation

@i2h3
Copy link
Collaborator

@i2h3 i2h3 commented Feb 9, 2026

No description provided.

…ging in debug builds.

Also fixed some unnecessary masking.

Signed-off-by: Iva Horn <iva.horn@nextcloud.com>
@i2h3 i2h3 added this to the 33.0.0 milestone Feb 9, 2026
@i2h3 i2h3 self-assigned this Feb 9, 2026
Copilot AI review requested due to automatic review settings February 9, 2026 15:31
@i2h3 i2h3 added the feature: 📁 file provider macOS File Provider Extension, more general also known as virtual file system. label Feb 9, 2026
@github-project-automation github-project-automation bot moved this to 🧭 Planning evaluation (don't pick) in 💻 Desktop Clients team Feb 9, 2026
@i2h3 i2h3 moved this from 🧭 Planning evaluation (don't pick) to 🏗️ In progress in 💻 Desktop Clients team Feb 9, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the File Provider logging stack to capture and (in debug builds) emit source location context (file, function, line) alongside existing structured log details.

Changes:

  • Extended FileProviderLogging.write(...) and FileProviderLogger.{debug,info,error,fault} to thread through file/function/line.
  • Added file/function/line fields to FileProviderLogMessage and encoded them only in #if DEBUG.
  • Appended source location to unified logging output (debug builds) and adjusted some path interpolations to use explicit .public privacy.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
.../Log/FileProviderLogging.swift Updates the logging protocol API to carry source location info.
.../Log/FileProviderLogger.swift Passes caller #filePath/#function/#line through the logger convenience methods.
.../Log/FileProviderLogMessage.swift Adds source fields to the JSON log model and conditionally encodes them in debug builds.
.../Log/FileProviderLog.swift Threads source location through log writing and appends it to unified logs (debug).
Comments suppressed due to low confidence (1)

shell_integration/MacOSX/NextcloudFileProviderKit/Sources/NextcloudFileProviderKit/Log/FileProviderLog.swift:219

  • When details is empty you early-return after logging only the message, so the new file:function:line context is omitted for those log entries. To match the PR’s intent, include the source location even when there are no details (e.g., log message + "file:line function" in the empty-details branch too).
        if details.isEmpty {
            logger.log(level: level, "\(message, privacy: .public)")
            return
        }

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

Comment on lines +20 to 25
/// - file: Implementations should have `#filePath` as the default value for this.
/// - function: Implementations should have `#function` as the default value for this.
/// - line: Implementations should have `#line` as the default value for this.
///
func write(category: String, level: OSLogType, message: String, details: [FileProviderLogDetailKey: (any Sendable)?], file: StaticString, function: StaticString, line: UInt)
}
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

This protocol requirement change is source-breaking for existing conformers. For example, FileProviderLogMock in Sources/NextcloudFileProviderKitMocks/FileProviderLogMock.swift still implements the old write(..., details:) signature, so the project won’t compile until it’s updated (or until you provide a backward-compatible overload/default implementation). Consider keeping the old requirement and adding a new overload in a protocol extension that supplies file/function/line defaults and forwards appropriately.

Suggested change
/// - file: Implementations should have `#filePath` as the default value for this.
/// - function: Implementations should have `#function` as the default value for this.
/// - line: Implementations should have `#line` as the default value for this.
///
func write(category: String, level: OSLogType, message: String, details: [FileProviderLogDetailKey: (any Sendable)?], file: StaticString, function: StaticString, line: UInt)
}
///
func write(category: String, level: OSLogType, message: String, details: [FileProviderLogDetailKey: (any Sendable)?])
}
public extension FileProviderLogging {
///
/// Convenience overload that supplies file/function/line defaults and forwards
/// to the base `write` requirement.
///
/// - Parameters:
/// - category: The unified logging category to use. Usually, this is the logging type.
/// - level: The severity of the message.
/// - message: A human-readable message, preferrably generic and without interpolations. The `details` argument is for arguments.
/// - details: Structured and contextual details about a message.
/// - file: The file path from which the log was emitted. Defaults to `#filePath`.
/// - function: The function from which the log was emitted. Defaults to `#function`.
/// - line: The line number from which the log was emitted. Defaults to `#line`.
///
func write(
category: String,
level: OSLogType,
message: String,
details: [FileProviderLogDetailKey: (any Sendable)?],
file: StaticString = #filePath,
function: StaticString = #function,
line: UInt = #line
) {
// Default implementation ignores file/function/line and forwards to the
// base requirement for backward compatibility.
self.write(category: category, level: level, message: message, details: details)
}
}

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +18
/// - level: The severit of the message.
/// - message: A human-readable message, preferrably generic and without interpolations. The `details` argument is for arguments.
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

Doc typos: "severit" should be "severity", and "preferrably" should be "preferably".

Suggested change
/// - level: The severit of the message.
/// - message: A human-readable message, preferrably generic and without interpolations. The `details` argument is for arguments.
/// - level: The severity of the message.
/// - message: A human-readable message, preferably generic and without interpolations. The `details` argument is for arguments.

Copilot uses AI. Check for mistakes.
Comment on lines 39 to +46
/// - Parameters:
/// - message: The main text message of the entry in the logs.
/// - details: Additional contextual data.
///
public func debug(_ message: String, _ details: [FileProviderLogDetailKey: (any Sendable)?] = [:]) {
/// - category: The unified logging category to use. Usually, this is the logging type.
/// - level: The severit of the message.
/// - message: A human-readable message, preferrably generic and without interpolations. The `details` argument is for arguments.
/// - details: Structured and contextual details about a message.
/// - file: Implementations should have `#filePath` as the default value for this.
/// - function: Implementations should have `#function` as the default value for this.
/// - line: Implementations should have `#line` as the default value for this.
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

These doc comments list parameters (category, level) that are not parameters of debug(...) (and the same issue is repeated for info/error/fault). Please update the parameter docs to match the actual signature, and fix the typos ("severity", "preferably").

Copilot uses AI. Check for mistakes.
Comment on lines +85 to +97
public func encode(to encoder: any Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
try container.encode(category, forKey: .category)
try container.encode(date, forKey: .date)
try container.encode(details, forKey: .details)
try container.encode(level, forKey: .level)
try container.encode(message, forKey: .message)

#if DEBUG
try container.encode(file, forKey: .file)
try container.encode(function, forKey: .function)
try container.encode(line, forKey: .line)
#endif
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

FileProviderLogMessage now conditionally encodes file/function/line only in #if DEBUG, but there’s no test coverage to ensure the produced JSON includes these keys in debug builds (and excludes them otherwise). Add a unit test around encoding that asserts the expected keys based on the build configuration (using #if DEBUG in the test).

Copilot uses AI. Check for mistakes.
Comment on lines +78 to +79
self.file = String("\(file)")
self.function = String("\(function)")
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

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

Even in non-DEBUG builds, FileProviderLogMessage eagerly converts file/function to String and stores them, even though they won’t be encoded. If the goal is “debug builds only”, consider avoiding this work in release builds (e.g., set them only under #if DEBUG, or store them as optionals and encode only when present).

Suggested change
self.file = String("\(file)")
self.function = String("\(function)")
#if DEBUG
self.file = String("\(file)")
self.function = String("\(function)")
#else
// Avoid unnecessary conversion work in non-DEBUG builds; these fields are not encoded there.
self.file = ""
self.function = ""
#endif

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Feb 9, 2026

Artifact containing the AppImage: nextcloud-appimage-pr-9437.zip

Digest: sha256:1ad248c03b504aabbff93700db4dea2948eaf4411114649ff4e35eb30a3882a1

To test this change/fix you can download the above artifact file, unzip it, and run it.

Please make sure to quit your existing Nextcloud app and backup your data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: 📁 file provider macOS File Provider Extension, more general also known as virtual file system.

Projects

Status: 🏗️ In progress

Development

Successfully merging this pull request may close these issues.

1 participant