LogStream

1.3.0

Wouter01/LogStream

What's New

v1.3.0

2024-04-26T02:36:00Z

Note

This release changes the way the package is used. Previous to v1.3.0, build settings needed to be changed in order to correctly link with the LoggingSupport framework. Now, the framework will be linked at runtime, dropping the requirement to change build settings. When not needed anymore, you can remove the $(DEVELOPER_SDK_DIR)/MacOSX.sdk/System/Library/PrivateFrameworks entry in Build Settings -> System Framework Search Paths

Changes

  • Added Sendable conformance to LogMessage and ActivityStreamOptions
  • Fixed most concurrency warnings
  • Removed OSLogType Hashable conformance
  • LoggingSupport is now loaded at runtime

LogStream

This package provides some utilities to capture logs of other processes. This can be useful when working with extensions using ExtensionKit.

The logs captured are the same ones visible in Console.app.

Important

This package makes use of the private framework LoggingSupport. While unlikely, OS updates might change the internals of the framework and break this package.

Usage

Capturing logs for one process:

// Specify the process identifier of which to capture logs.
let pid: pid_t = ...
let logStream = LogStream.logs(for: pid)

Task {
    for await log in logStream {
        print("\(log.process) says: \(log.message)")
    }
}

Logs of multiple processes can also be captures with another initializer:

public static func logs(for processIDs: [pid_t], flags: ActivityStreamOptions) -> AsyncStream<LogMessage>

To capture logs of all processes, use the following initializer:

public static func logs(flags: ActivityStreamOptions) -> AsyncStream<LogMessage>

Description

  • Swift Tools 5.8.0
View More Packages from this Author

Dependencies

  • None
Last updated: Mon May 06 2024 03:55:37 GMT-0900 (Hawaii-Aleutian Daylight Time)