Debug with structured logging

RSS for tag

Discuss the WWDC23 Session Debug with structured logging

Posts under wwdc2023-10226 tag

5 Posts

Post

Replies

Boosts

Views

Activity

Structured logging with emoji or objectdescription
When running the code below, only the first entry gets logged. Structured logging seems not to work when there are emoticons or object descriptions in the message. Is this by design? let logger = Logger(subsystem: "TestSystem", category: "TestCategory") logger.log("👍") // Result = 👍 let someEmoji:String = "👎" logger.log("\(someEmoji)") // Result = empty log line let someObjectDescription:String = String(describing:self) logger.log("\(someObjectDescription)") // Result = empty log line
3
0
1.3k
Oct ’23
Cannot get incremental logs from OSLogStore
Hello folks, I would like to incrementally retrieve logs of my iOS App from the Unified Logging System using OSLogStore. First I initialize the store store = try OSLogStore(scope: .currentProcessIdentifier) Second I set a position from which I want the logs using either : position = store.position(timeIntervalSinceLatestBoot: 0) // to get the logs from the launch of the App position = store.position(date: Date().addingTimeInterval(-10)) // to get the logs of the last 10 seconds Third I get the entries in the store from the position store.getEntries(at: position) Issue Whatever the position I set using from OSLogStore: position(timeIntervalSinceLatestBoot:) position(date:) position(timeIntervalSinceEnd:) All the logs are retrieved. I cannot get only the subset requested by the timeframe I specified Sample A sample LogScreen that has 2 buttons is attached to the post 1 to fetch logs since the last time they have been fetched 1 to add a log The code has been simplified to ease the comprehension of the case, please be indulgent to the shortcuts that have been taken. LogScreen.swift References https://developer.apple.com/documentation/oslog/oslogstore https://developer.apple.com/forums/thread/705868 https://developer.apple.com/videos/play/wwdc2023/10226/ Environment XCode 15b7 iPhone 14 Pro / iOS 17
1
1
1k
Sep ’23
Xcode 15 structured logging not working for existing project
Using the latest Xcode 15 Beta 7: In an existing project, I can't get structured logging to work as described. For new projects, it works fine but I must have some setting or value in an existing project that prevents it from working. My simple text case: In an existing project file: @main struct LuarasBooksApp: App { var body: some Scene { WindowGroup { Text("hi") .onAppear { Logger(subsystem: "test", category: "test").error("help me") } } } } The debug console looks like this: That same code in a new project for the same Xcode 15 Beta 7 looks correct: Are there any settings, variables, etc... related to logging or the console that might cause this difference? In the existing project it makes no difference to toggle the various metadata options on and off. Thanks!
5
2
4.6k
Aug ’23
structured logging is great, but logging fails with variables ?
I wanted to try structured logging with os_log in C++, but I found that it fails to print anything given a format string and a variable: eg. void example(std::string& str) { os_log_info(OS_LOG_DEFAULT, "%s", str.c_str()); os_log_debug(OS_LOG_DEFAULT, "%s", str.c_str()); os_log_error(OS_LOG_DEFAULT, "%s", str.c_str()); } This prints a blank row in the console, but with no text. How is this meant to work with variables? It only works with literals and constants now as far as I can tell. I'm looking forward to getting this working.
10
0
3.1k
Jun ’23
Structured logging with emoji or objectdescription
When running the code below, only the first entry gets logged. Structured logging seems not to work when there are emoticons or object descriptions in the message. Is this by design? let logger = Logger(subsystem: "TestSystem", category: "TestCategory") logger.log("👍") // Result = 👍 let someEmoji:String = "👎" logger.log("\(someEmoji)") // Result = empty log line let someObjectDescription:String = String(describing:self) logger.log("\(someObjectDescription)") // Result = empty log line
Replies
3
Boosts
0
Views
1.3k
Activity
Oct ’23
Cannot get incremental logs from OSLogStore
Hello folks, I would like to incrementally retrieve logs of my iOS App from the Unified Logging System using OSLogStore. First I initialize the store store = try OSLogStore(scope: .currentProcessIdentifier) Second I set a position from which I want the logs using either : position = store.position(timeIntervalSinceLatestBoot: 0) // to get the logs from the launch of the App position = store.position(date: Date().addingTimeInterval(-10)) // to get the logs of the last 10 seconds Third I get the entries in the store from the position store.getEntries(at: position) Issue Whatever the position I set using from OSLogStore: position(timeIntervalSinceLatestBoot:) position(date:) position(timeIntervalSinceEnd:) All the logs are retrieved. I cannot get only the subset requested by the timeframe I specified Sample A sample LogScreen that has 2 buttons is attached to the post 1 to fetch logs since the last time they have been fetched 1 to add a log The code has been simplified to ease the comprehension of the case, please be indulgent to the shortcuts that have been taken. LogScreen.swift References https://developer.apple.com/documentation/oslog/oslogstore https://developer.apple.com/forums/thread/705868 https://developer.apple.com/videos/play/wwdc2023/10226/ Environment XCode 15b7 iPhone 14 Pro / iOS 17
Replies
1
Boosts
1
Views
1k
Activity
Sep ’23
New debug console in Xcode 15 not active?
Hi! I am getting all debug output in text only format, without structure or color. I only noticed now after watching the respective WWDC session in Xcode 15 beta 8, but I am pretty sure this was the case in the previous betas as well. Is the new structured debug console activated by some setting I am overlooking?
Replies
1
Boosts
0
Views
2.5k
Activity
Sep ’23
Xcode 15 structured logging not working for existing project
Using the latest Xcode 15 Beta 7: In an existing project, I can't get structured logging to work as described. For new projects, it works fine but I must have some setting or value in an existing project that prevents it from working. My simple text case: In an existing project file: @main struct LuarasBooksApp: App { var body: some Scene { WindowGroup { Text("hi") .onAppear { Logger(subsystem: "test", category: "test").error("help me") } } } } The debug console looks like this: That same code in a new project for the same Xcode 15 Beta 7 looks correct: Are there any settings, variables, etc... related to logging or the console that might cause this difference? In the existing project it makes no difference to toggle the various metadata options on and off. Thanks!
Replies
5
Boosts
2
Views
4.6k
Activity
Aug ’23
structured logging is great, but logging fails with variables ?
I wanted to try structured logging with os_log in C++, but I found that it fails to print anything given a format string and a variable: eg. void example(std::string& str) { os_log_info(OS_LOG_DEFAULT, "%s", str.c_str()); os_log_debug(OS_LOG_DEFAULT, "%s", str.c_str()); os_log_error(OS_LOG_DEFAULT, "%s", str.c_str()); } This prints a blank row in the console, but with no text. How is this meant to work with variables? It only works with literals and constants now as far as I can tell. I'm looking forward to getting this working.
Replies
10
Boosts
0
Views
3.1k
Activity
Jun ’23