When I change to log my messages from print to os_log, it indeed provided very detail timestamp for each message. But sometimes I does not need the long timestamp information occupied screen space.
How to hide/reformat the Xcode's console or could I configure OSLog to not show timestamp for a while? Or I should use print instead?
Here is my logger use
let logger = OSLog(subsystem: "com.my.myapp", category: "MediaObj")
os_log(.debug, log: logger, "....my...message...")

Starting with Xcode 15, when using debug console in Xcode along with Apple's unified logging framework, one can opt to see relevant data in Xcode's console.
One can use unified logger framework like below :
import OSLog
extension Logger {
private static let subsystem = Bundle.main.bundleIdentifier!
}
extension Logger {
static let appCycle = Logger(subsystem: subsystem, category: "appCycle")
}
Then add loggers, for example :
Logger.appCycle.info("SwiftUILearnings scenePhase : Active")
Now on Xcode debug console one views loggers as in screenshot below with all metadata information including timestamp, also there is a Metadata Options toggle as well which allows one to choose what info to display, as well as turn off all the metadata information :

If timestamp is turned off :

If all the metadata is switched off :

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With