Skip to content

Commit e3a6bc8

Browse files
committed
Add more logging to GitHub Copilot
1 parent 114dfc0 commit e3a6bc8

4 files changed

Lines changed: 30 additions & 3 deletions

File tree

Core/Sources/GitHubCopilotService/CopilotLocalProcessServer.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Foundation
22
import JSONRPC
33
import LanguageClient
44
import LanguageServerProtocol
5-
5+
import Logger
66
import ProcessEnv
77

88
/// A clone of the `LocalProcessServer`.
@@ -167,10 +167,25 @@ extension CustomJSONRPCLanguageServer {
167167
) -> Bool {
168168
let methodName = anyNotification.method
169169
switch methodName {
170+
case "window/logMessage":
171+
if UserDefaults.shared.value(for: \.gitHubCopilotVerboseLog) {
172+
Logger.gitHubCopilot
173+
.info("\(anyNotification.method): \(anyNotification.params.debugDescription)")
174+
}
175+
block(nil)
176+
return true
170177
case "LogMessage":
178+
if UserDefaults.shared.value(for: \.gitHubCopilotVerboseLog) {
179+
Logger.gitHubCopilot
180+
.info("\(anyNotification.method): \(anyNotification.params.debugDescription)")
181+
}
171182
block(nil)
172183
return true
173184
case "statusNotification":
185+
if UserDefaults.shared.value(for: \.gitHubCopilotVerboseLog) {
186+
Logger.gitHubCopilot
187+
.info("\(anyNotification.method): \(anyNotification.params.debugDescription)")
188+
}
174189
block(nil)
175190
return true
176191
default:

Core/Sources/GitHubCopilotService/GitHubCopilotService.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public final class GitHubCopilotSuggestionService: GitHubCopilotBaseService, Git
261261
) async throws {
262262
let languageId = languageIdentifierFromFileURL(fileURL)
263263
let uri = "file://\(fileURL.path)"
264-
// Logger.service.debug("Open \(uri)")
264+
// Logger.service.debug("Open \(uri), \(content.count)")
265265
try await server.sendNotification(
266266
.didOpenTextDocument(
267267
DidOpenTextDocumentParams(
@@ -278,7 +278,7 @@ public final class GitHubCopilotSuggestionService: GitHubCopilotBaseService, Git
278278

279279
public func notifyChangeTextDocument(fileURL: URL, content: String) async throws {
280280
let uri = "file://\(fileURL.path)"
281-
// Logger.service.debug("Change \(uri)")
281+
// Logger.service.debug("Change \(uri), \(content.count)")
282282
try await server.sendNotification(
283283
.didChangeTextDocument(
284284
DidChangeTextDocumentParams(

Core/Sources/Logger/Logger.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public final class Logger {
1515
public static let ui = Logger(category: "UI")
1616
public static let client = Logger(category: "Client")
1717
public static let updateChecker = Logger(category: "UpdateChecker")
18+
public static let gitHubCopilot = Logger(category: "GitHubCopilot")
1819

1920
public init(subsystem: String = "com.intii.CopilotForXcode", category: String) {
2021
self.subsystem = subsystem

Core/Sources/Preferences/Keys.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,17 @@ public extension UserDefaultPreferenceKeys {
230230
var chatGPTTemperature: ChatGPTTemperature { .init() }
231231
}
232232

233+
// MARK: - GitHubCopilot Account Settings
234+
235+
public extension UserDefaultPreferenceKeys {
236+
struct GitHubCopilotVerboseLog: UserDefaultPreferenceKey {
237+
public let defaultValue = false
238+
public let key = "GitHubCopilotVerboseLog"
239+
}
240+
241+
var gitHubCopilotVerboseLog: GitHubCopilotVerboseLog { .init() }
242+
}
243+
233244
// MARK: - UI
234245

235246
public extension UserDefaultPreferenceKeys {

0 commit comments

Comments
 (0)