Skip to content
Open
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
14 changes: 14 additions & 0 deletions Sources/Basics/Observability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public class ObservabilitySystem {
func handleDiagnostic(scope: ObservabilityScope, diagnostic: Diagnostic) {
self.underlying(scope, diagnostic)
}

func print(message: String) {
self.diagnosticsHandler.print(message: message)
}
}

public static var NOOP: ObservabilityScope {
Expand Down Expand Up @@ -128,6 +132,10 @@ public final class ObservabilityScope: DiagnosticsEmitterProtocol, Sendable, Cus
return parent?.errorsReportedInAnyScope ?? false
}

public func print(message: String) {
self.diagnosticsHandler.print(message: message)
}

// DiagnosticsEmitterProtocol
public func emit(_ diagnostic: Diagnostic) {
var diagnostic = diagnostic
Expand All @@ -150,6 +158,10 @@ public final class ObservabilityScope: DiagnosticsEmitterProtocol, Sendable, Cus
self.underlying.handleDiagnostic(scope: scope, diagnostic: diagnostic)
}

public func print(message: String) {
self.underlying.print(message: message)
}

var errorsReported: Bool {
self._errorsReported.get() ?? false
}
Expand All @@ -160,6 +172,8 @@ public final class ObservabilityScope: DiagnosticsEmitterProtocol, Sendable, Cus

public protocol DiagnosticsHandler: Sendable {
func handleDiagnostic(scope: ObservabilityScope, diagnostic: Diagnostic)

func print(message: String)
}

/// Helper protocol to share default behavior.
Expand Down
6 changes: 6 additions & 0 deletions Sources/CoreCommands/SwiftCommandObservabilityHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ public struct SwiftCommandObservabilityHandler: ObservabilityHandlerProvider {
}
}

func print(message: String) {
self.queue.async(group: self.sync) {
self.write(message)
}
}

// for raw output reporting
func print(_ output: String, verbose: Bool) {
self.queue.async(group: self.sync) {
Expand Down
Loading
Loading