Created
February 16, 2023 00:49
-
-
Save AlexKobachiJP/e84624a42a5f35fa6ccc96a1e73ed59f to your computer and use it in GitHub Desktop.
Fallback for Console.app not picking up debug/trace logs for simulator devices on macOS 13.2.1 (22D68)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copyright © 2023 Alex Kovács. All rights reserved. | |
#if targetEnvironment(simulator) | |
import OSLog | |
extension Logger { | |
/// Hack! Cannot get Console.app to pick up trace logs from simulator (as of macOS 13.2.1 (22D68)), so just falling | |
/// back to info level logs for debugging. This shadows the existing [Logger.trace()](https://developer.apple.com/documentation/os/logger/3551624-trace) function which | |
/// works because the existing function takes ` OSLogMessage` and one never creates those directly but relies on the | |
/// system to create them automatically from interpolated strings. | |
public func trace(_ message: String) { | |
info("\(message)") | |
} | |
/// Hack! Cannot get Console.app to pick up debug logs from simulator (as of macOS 13.2.1 (22D68)), so just falling | |
/// back to info level logs for debugging. This shadows the existing [Logger.debug()](https://developer.apple.com/documentation/os/logger/3551615-debug) function which | |
/// works because the existing function takes ` OSLogMessage` and one never creates those directly but relies on the | |
/// system to create them automatically from interpolated strings. | |
public func debug(_ message: String) { | |
info("\(message)") | |
} | |
} | |
#endif | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment