Skip to content

Commit 58769c5

Browse files
committed
Fix log level option, use single dash in new options
1 parent 51c367c commit 58769c5

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

Sources/LSPLogging/Logging.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,10 @@ public final class Logger {
115115
}
116116
}
117117

118-
public func setLogLevel(environmentVariable: String) -> Bool {
118+
public func setLogLevel(environmentVariable: String) {
119119
if let string = ProcessInfo.processInfo.environment[environmentVariable] {
120120
setLogLevel(string)
121-
return true
122121
}
123-
124-
return false
125122
}
126123

127124
public func setLogLevel(_ logLevel: String) {

Sources/sourcekit-lsp/main.swift

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,6 @@ extension AbsolutePath: ExpressibleByArgument {
4242
}
4343
}
4444

45-
struct CommandLineOptions {
46-
/// Options for the server.
47-
var serverOptions: SourceKitServer.Options = SourceKitServer.Options()
48-
49-
var syncRequests: Bool = false
50-
}
51-
5245
extension LogLevel: ExpressibleByArgument {}
5346
extension BuildConfiguration: ExpressibleByArgument {}
5447

@@ -62,12 +55,12 @@ struct Main: ParsableCommand {
6255
@Flag(name: .customLong("sync"))
6356
var syncRequests = false
6457

65-
@Option(help: "Set the logging level (debug|info|warning|error)")
66-
var logLevel: LogLevel = LogLevel.default
58+
@Option(help: "Set the logging level [debug|info|warning|error] (default: \(LogLevel.default))")
59+
var logLevel: LogLevel?
6760

6861
@Option(
6962
name: [.customLong("configuration"), .customShort("c")],
70-
help: "Build with configuration (debug|release)"
63+
help: "Build with configuration [debug|release]"
7164
)
7265
var buildConfiguration = BuildConfiguration.debug
7366

@@ -122,13 +115,11 @@ struct Main: ParsableCommand {
122115
var indexDatabasePath: AbsolutePath?
123116

124117
@Option(
125-
name: .customLong("completion-server-side-filtering", withSingleDash: true),
126118
help: "Whether to enable server-side filtering in code-completion"
127119
)
128120
var completionServerSideFiltering = true
129121

130122
@Option(
131-
name: .customLong("completion-max-results", withSingleDash: true),
132123
help: "When server-side filtering is enabled, the maximum number of results to return"
133124
)
134125
var completionMaxResults = 200
@@ -152,8 +143,10 @@ struct Main: ParsableCommand {
152143
}
153144

154145
func run() throws {
155-
if !Logger.shared.setLogLevel(environmentVariable: "SOURCEKIT_LOGGING") {
146+
if let logLevel = logLevel {
156147
Logger.shared.currentLevel = logLevel
148+
} else {
149+
Logger.shared.setLogLevel(environmentVariable: "SOURCEKIT_LOGGING")
157150
}
158151

159152
// Dup stdout and redirect the fd to stderr so that a careless print()

0 commit comments

Comments
 (0)