Skip to content

Commit

Permalink
Fix 5.8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Wouter01 committed Apr 26, 2024
1 parent 5378baf commit 6f83694
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Sources/LogStream/LogMessage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ extension LogMessage: Hashable {
}

extension LogMessage {
init(_ event: LoggingSupport._OSActivityLogMessageEvent) {
init(_ event: _OSActivityLogMessageEvent) {
self.init(
message: event.eventMessage,
date: event.timestamp,
Expand Down
2 changes: 1 addition & 1 deletion Sources/LogStream/LogStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public enum LogStream {
LogStream.logs(for: -1, flags: flags)
}

static let messageClass = unsafeBitCast(NSClassFromString("OSActivityLogMessageEvent"), to: LoggingSupport._OSActivityLogMessageEvent.Type.self)
static let messageClass = unsafeBitCast(NSClassFromString("OSActivityLogMessageEvent"), to: _OSActivityLogMessageEvent.Type.self)

static func createStream(
pid: pid_t,
Expand Down
31 changes: 18 additions & 13 deletions Sources/LogStream/LoggingSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@ import Foundation
import ExternalAppLoggerHeaders

enum LoggingSupport {
#if swift(>=5.10)
nonisolated(unsafe) static let handle = dlopen("/System/Library/PrivateFrameworks/LoggingSupport.framework/LoggingSupport", RTLD_LAZY),
streamLog = unsafeBitCast(dlsym(handle, "os_activity_stream_for_pid"), to: StreamLog.self),
resumeLog = unsafeBitCast(dlsym(handle, "os_activity_stream_resume"), to: ResumeLog.self),
cancelLog = unsafeBitCast(dlsym(handle, "os_activity_stream_cancel"), to: CancelLog.self)
#else
static let handle = dlopen("/System/Library/PrivateFrameworks/LoggingSupport.framework/LoggingSupport", RTLD_LAZY),
streamLog = unsafeBitCast(dlsym(handle, "os_activity_stream_for_pid"), to: StreamLog.self),
resumeLog = unsafeBitCast(dlsym(handle, "os_activity_stream_resume"), to: ResumeLog.self),
cancelLog = unsafeBitCast(dlsym(handle, "os_activity_stream_cancel"), to: CancelLog.self)
#endif

typealias StreamLog = @convention(c) (
pid_t,
Expand All @@ -27,17 +34,15 @@ enum LoggingSupport {
typealias ActivityStream = OpaquePointer
}

extension LoggingSupport {
@objc
protocol _OSActivityLogMessageEvent {
var eventMessage: String { get set }
var timestamp: Date { get set }
var subsystem: String? { get set }
var category: String? { get set }
var messageType: UInt8 { get set }
var process: String { get set }
var processID: pid_t { get set }

init(entry: UnsafeMutablePointer<os_activity_stream_entry_s>)
}
@objc
protocol _OSActivityLogMessageEvent {
var eventMessage: String { get set }
var timestamp: Date { get set }
var subsystem: String? { get set }
var category: String? { get set }
var messageType: UInt8 { get set }
var process: String { get set }
var processID: pid_t { get set }

init(entry: UnsafeMutablePointer<os_activity_stream_entry_s>)
}

0 comments on commit 6f83694

Please sign in to comment.