Files
sourcekit-lsp/Sources/SourceKitLSP/IndexStoreDB+MainFilesProvider.swift
Alex Hoppen f960d7ed9b Change logging to use OSLog
OSLog is the suggesting logging solution on Apple platforms and we should be using it there, taking advantage of the different log levels and privacy masking.

Switch sourcekit-lsp to use OSLog on Apple platforms and implement a logger that is API-compatible with OSLog for all uses in sourcekit-lsp and which can be used on non-Darwin platforms.

The goal of this commit is to introduce the new logging API. There are still improvements about what we log and we can display more privacy-insensitive information after masking. Those changes will be in follow-up commits.
2023-10-13 13:46:32 -07:00

33 lines
1.1 KiB
Swift

//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import IndexStoreDB
import LSPLogging
import LanguageServerProtocol
import SKCore
extension IndexStoreDB: MainFilesProvider {
public func mainFilesContainingFile(_ uri: DocumentURI) -> Set<DocumentURI> {
let mainFiles: Set<DocumentURI>
if let url = uri.fileURL {
mainFiles = Set(
self.mainFilesContainingFile(path: url.path)
.lazy.map({ DocumentURI(URL(fileURLWithPath: $0, isDirectory: false)) })
)
} else {
mainFiles = []
}
logger.info("mainFilesContainingFile(\(uri.forLogging)) -> \(mainFiles)")
return mainFiles
}
}