Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide os_log timestamp prepended in Xcode console?

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...")

enter image description here

like image 771
Chen OT Avatar asked Nov 24 '25 14:11

Chen OT


1 Answers

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 :

enter image description here

If timestamp is turned off :

enter image description here

If all the metadata is switched off :

enter image description here

like image 137
Saurabh Verma Avatar answered Nov 26 '25 22:11

Saurabh Verma



Donate For Us

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