Files
schihei 7ca5c710ec feat(m0): complete scaffold, logging and signature checks (T0.2-T0.6)
Add os.Logger categories, OSSignposter wrapper and shortHash helper; enforce exact Debug/Release/install signatures; lint tests; update M0 docs and progress.
2026-11-26 12:33:51 +01:00

30 lines
1.1 KiB
Swift

import os
/// Thin wrapper around `OSSignposter` that uses the names from ARCHITECTURE §15.
///
/// Leaf modules cannot import Core; the composition root can pass an `OSSignposter` directly to
/// them, using the literal names in ARCHITECTURE §15.
public struct Signposts: Sendable {
private let signposter: OSSignposter
init(subsystem: String, category: LogCategory) {
signposter = OSSignposter(subsystem: subsystem, category: category.rawValue)
}
/// Starts an interval; pair it with ``end(_:)`` on the same task.
public func begin(_ name: SignpostName) -> SignpostInterval {
let state = signposter.beginInterval(name.literal)
return SignpostInterval(name: name, state: state, signposter: signposter)
}
/// Ends an interval started by ``begin(_:)``.
public func end(_ interval: SignpostInterval) {
interval.signposter.endInterval(interval.name.literal, interval.state)
}
/// Emits a single signpost event.
public func event(_ name: SignpostName) {
signposter.emitEvent(name.literal)
}
}