Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion Sources/SKOptions/SourceKitLSPOptions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
public import Foundation
public import LanguageServerProtocol
import LanguageServerProtocolExtensions
import SKLogging
package import SKLogging

import struct TSCBasic.AbsolutePath

Expand Down Expand Up @@ -500,6 +500,10 @@ public struct SourceKitLSPOptions: Sendable, Codable, Equatable {
else {
return nil
}

logger.log("Read options from \(path)")
logger.logFullObjectInMultipleLogMessages(header: "Config file options", loggingProxy)

self = decoded
}

Expand Down Expand Up @@ -561,3 +565,25 @@ public struct SourceKitLSPOptions: Sendable, Codable, Equatable {
return experimentalFeatures.contains(feature)
}
}

extension SourceKitLSPOptions {
/// Options proxy to avoid public import of `SKLogging`.
///
/// We can't conform `SourceKitLSPOptions` to `CustomLogStringConvertible` because that would require a public import
/// of `SKLogging`. Instead, define a package type that performs the logging of `SourceKitLSPOptions`.
package struct LoggingProxy: CustomLogStringConvertible {
let options: SourceKitLSPOptions

package var description: String {
options.prettyPrintedJSON
}

package var redactedDescription: String {
options.prettyPrintedRedactedJSON
}
}

package var loggingProxy: LoggingProxy {
LoggingProxy(options: self)
}
}
28 changes: 2 additions & 26 deletions Sources/SourceKitLSP/SourceKitLSPServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ extension SourceKitLSPServer {
)
)
logger.log("Creating workspace at \(workspaceFolder.forLogging)")
logger.logFullObjectInMultipleLogMessages(header: "Options for workspace", options.loggingProxy)
logger.logFullObjectInMultipleLogMessages(header: "Workspace options", options.loggingProxy)

let workspace = await Workspace(
sourceKitLSPServer: self,
Expand Down Expand Up @@ -1003,7 +1003,7 @@ extension SourceKitLSPServer {
}

logger.log("Initialized SourceKit-LSP")
logger.logFullObjectInMultipleLogMessages(header: "SourceKit-LSP Options", options.loggingProxy)
logger.logFullObjectInMultipleLogMessages(header: "Global options", options.loggingProxy)

await workspaceQueue.async { [hooks] in
if let workspaceFolders = req.workspaceFolders {
Expand Down Expand Up @@ -2807,27 +2807,3 @@ fileprivate extension URL {
return other.pathComponents[0..<self.pathComponents.count] == self.pathComponents[...]
}
}

extension SourceKitLSPOptions {
/// We can't conform `SourceKitLSPOptions` to `CustomLogStringConvertible` because that would require a public import
/// of `SKLogging`. Instead, define an internal type that performs the logging of `SourceKitLSPOptions`.
struct LoggingProxy: CustomLogStringConvertible {
let options: SourceKitLSPOptions

var description: String {
options.prettyPrintedJSON
}

var redactedDescription: String {
options.prettyPrintedRedactedJSON
}
}

var loggingProxy: LoggingProxy {
LoggingProxy(options: self)
}

var forLogging: CustomLogStringConvertibleWrapper {
return self.loggingProxy.forLogging
}
}