Skip to content

Commit

Permalink
add logging for all processes
Browse files Browse the repository at this point in the history
Signed-off-by: Wouter01 <[email protected]>
  • Loading branch information
Wouter01 committed May 22, 2023
1 parent 5b420bb commit fad742c
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions Sources/LogStream/LogStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ public enum LogStream {
/// - flags: The options specifying the behavior of the activity stream. Default value is `[.historical, .processOnly]`.
/// - Returns: An `AsyncStream` that emits `LogMessage` objects representing the activity logs.
///
/// The `logs(for:flags:)` method retrieves activity logs for a specific process identified by its PID. It returns an `AsyncStream`
/// that emits `LogMessage` objects representing the activity logs for the process.
///
/// Usage Example:
///
/// ```swift
Expand All @@ -27,7 +24,6 @@ public enum LogStream {
///
/// Task {
/// for await log in logStream {
/// // Process the log message
/// print(log)
/// }
/// }
Expand Down Expand Up @@ -66,6 +62,25 @@ public enum LogStream {
resumeLog(stream: stream)
}
}

/// Retrieve activity logs for all processes using an asynchronous stream.
///
/// - Parameters:
/// - flags: The options specifying the behavior of the activity stream. Default value is `[.historical, .processOnly]`.
/// - Returns: An `AsyncStream` that emits `LogMessage` objects representing the activity logs.
///
/// Usage Example:
///
/// ```swift
/// Task {
/// for await log in LogStream.logs() {
/// print(log)
/// }
/// }
/// ```
public static func logs(flags: ActivityStreamOptions = [.historical, .processOnly]) -> AsyncStream<LogMessage> {
LogStream.logs(for: -1, flags: flags)
}
}

typealias ActivityStream = os_activity_stream_t
Expand Down

0 comments on commit fad742c

Please sign in to comment.