Skip to content

Commit 57ec880

Browse files
authored
Merge pull request #2268 from bnbarham/log-all-configs
Log each read config
2 parents b885439 + cce655f commit 57ec880

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

Sources/SKOptions/SourceKitLSPOptions.swift

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public import Foundation
1414
public import LanguageServerProtocol
1515
import LanguageServerProtocolExtensions
16-
import SKLogging
16+
package import SKLogging
1717

1818
import struct TSCBasic.AbsolutePath
1919

@@ -500,6 +500,10 @@ public struct SourceKitLSPOptions: Sendable, Codable, Equatable {
500500
else {
501501
return nil
502502
}
503+
504+
logger.log("Read options from \(path)")
505+
logger.logFullObjectInMultipleLogMessages(header: "Config file options", loggingProxy)
506+
503507
self = decoded
504508
}
505509

@@ -561,3 +565,25 @@ public struct SourceKitLSPOptions: Sendable, Codable, Equatable {
561565
return experimentalFeatures.contains(feature)
562566
}
563567
}
568+
569+
extension SourceKitLSPOptions {
570+
/// Options proxy to avoid public import of `SKLogging`.
571+
///
572+
/// We can't conform `SourceKitLSPOptions` to `CustomLogStringConvertible` because that would require a public import
573+
/// of `SKLogging`. Instead, define a package type that performs the logging of `SourceKitLSPOptions`.
574+
package struct LoggingProxy: CustomLogStringConvertible {
575+
let options: SourceKitLSPOptions
576+
577+
package var description: String {
578+
options.prettyPrintedJSON
579+
}
580+
581+
package var redactedDescription: String {
582+
options.prettyPrintedRedactedJSON
583+
}
584+
}
585+
586+
package var loggingProxy: LoggingProxy {
587+
LoggingProxy(options: self)
588+
}
589+
}

Sources/SourceKitLSP/SourceKitLSPServer.swift

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,7 @@ extension SourceKitLSPServer {
917917
)
918918
)
919919
logger.log("Creating workspace at \(workspaceFolder.forLogging)")
920-
logger.logFullObjectInMultipleLogMessages(header: "Options for workspace", options.loggingProxy)
920+
logger.logFullObjectInMultipleLogMessages(header: "Workspace options", options.loggingProxy)
921921

922922
let workspace = await Workspace(
923923
sourceKitLSPServer: self,
@@ -1003,7 +1003,7 @@ extension SourceKitLSPServer {
10031003
}
10041004

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

10081008
await workspaceQueue.async { [hooks] in
10091009
if let workspaceFolders = req.workspaceFolders {
@@ -2822,27 +2822,3 @@ fileprivate extension URL {
28222822
return other.pathComponents[0..<self.pathComponents.count] == self.pathComponents[...]
28232823
}
28242824
}
2825-
2826-
extension SourceKitLSPOptions {
2827-
/// We can't conform `SourceKitLSPOptions` to `CustomLogStringConvertible` because that would require a public import
2828-
/// of `SKLogging`. Instead, define an internal type that performs the logging of `SourceKitLSPOptions`.
2829-
struct LoggingProxy: CustomLogStringConvertible {
2830-
let options: SourceKitLSPOptions
2831-
2832-
var description: String {
2833-
options.prettyPrintedJSON
2834-
}
2835-
2836-
var redactedDescription: String {
2837-
options.prettyPrintedRedactedJSON
2838-
}
2839-
}
2840-
2841-
var loggingProxy: LoggingProxy {
2842-
LoggingProxy(options: self)
2843-
}
2844-
2845-
var forLogging: CustomLogStringConvertibleWrapper {
2846-
return self.loggingProxy.forLogging
2847-
}
2848-
}

0 commit comments

Comments
 (0)