Post marked as unsolved
154
Views
In my sandboxed MacOS app I want to access OSLogStore programmatically to fetch logs for multi-component application (app, libraries, deriver) for further analysis. According to the documentation, - https://developer.apple.com/documentation/oslog/oslogstore/3366102-local the app should have com.apple.logging.local-storeentitlement.
I have added this entitlement "by hand" to the entitlement file as I I can't find a correspondent entry in the Xcode -> Sign & Capabilities interface.
When I run the app, I get Unsatisfied entitlements: com.apple.logging.local-store error and the app doesn't start.
If I remove the entitlement, the app can't get access to the logd subsystem.
How can I add com.apple.logging.local-store to my app?
Should I request this not visible via Xcode configuration UI from apple?
Thanks!
Post marked as unsolved
183
Views
I am trying to store or log the output of signpost end flag so that i can do further work on them without viewing them on instruments. following are the things i have already tried.
Tried to print the output of signpost emit functions such as below.
PSLog(ossignpostintervalbegin(slogHandleAssetLoading, signpostId, "Editor: First Render Complete"))
2. tried to view it in logs under derived data folder but could not find it anywhere.
I just want to either get the data logged by signpost to be stored in array or get printed on console so i can parse the logs of console and fetch it from there.
Post marked as unsolved
157
Views
Console.app shows a lot of logs from NEFilterPacketInterpose when you use a Network Extension (possibly a NEFilterPacketProvider) repeatedly.
I'm a bit worried by these from a performance point of view considering that: there is a huge number of them over time.
turning off developer mode via systemextensionsctl does not appear to disable those logs.
these logs are printed for release flavors of NEs not just debug flavors.
Questions:
Is this pointless worrying and it does not have any impact on performances?
Is there a way to turn them off (not just filter them in Console.app)?
Post marked as unsolved
135
Views
We are using Universal logging facility for our product. Product is built via Xcode. The product's workspace consists of multiple projects (dynamic/static libs, executables, system extension, applications) The code is a mix of CPP/Objective C/Swift, when CPP is a major language.
We expected oslog facility to output source information such as file name, module, function, source code line, but it does not happen neither in debug nor in release build. Is there anything we can do, beside adding the required constants explicitly to the oslog calls?
We tried to run a simpler project with the same usage of os_log facility and got controversial results. There were full source info in the debug build:
2020-10-07 11:30:45.194143+0300 0x15abcf Error 0x0 57515 0 <aaaa`f1() (main.cpp:23)> aaaa: [com.aa.bb:HHHHH] qqqfault:
And partial source info in the release build:
2020-10-07 13:02:19.072344+0300 0x16c5ee Error 0x0 58416 0 <aaaa`f1() (.cold.1)> aaaa: [com.aa.bb:HHHHH] qqqfault:
Post marked as solved
150
Views
I am looking for a logging solution that is usable after the app is released to help keep track of errors etc. Does the Apple "Unified Logging" allow you to do this? After a quick glance at the documentation it is not clear how I can view logs after release. If not is there any 'Apple way' of monitoring logs after release without having to use a third party solution like Firebase?
Post marked as unsolved
255
Views
'import OSLog' compiles well in all Xcode beta version including the 12.2, but makes an error "could not build Objective-C module 'OSLog'" in Xcode 12 release.
Replacing with 'import os.log' works.
I do not understand and cannot explain it.
What is wrong?
Post marked as unsolved
135
Views
In kext I use kprintf outputs log information for debugging. The running environment is product version: 10.14 buildversion: 18a391. After the system has been running for a period of time, I found that the log content is no longer updated by entering the command: log show -- predict 'process = = kernel " in the terminal. What's the reason? How to solve it! thank you!
Post marked as unsolved
164
Views
I've found Console.app much harder to use in recent years, and one of the issues is the firehose of data is much more difficult to examine when you don't know what you're looking for, especially if you have to turn on debug and info.
As an example of a tool, I'm posting a script I wrote to gather likely subsystem/category names from other binaries. It's crude, but does a decent job when you're not sure where to start
#!/usr/bin/swift
import Foundation
extension Process {
		class func launchedForLines(url: URL, args: [String], block: (String) -> Void) {
				let proc = Process(), pipe = Pipe(), eol = Data([0x0A])
				proc.executableURL = url
				proc.arguments = args
				proc.standardOutput = pipe
				proc.launch()
				let output = pipe.fileHandleForReading
				var buffer = Data(capacity: Int(LINE_MAX)), chunk = output.availableData
				while !chunk.isEmpty {
						buffer.append(chunk)
						while let range = buffer.range(of: eol) {
								let slice = buffer[0..<range.lowerBound]
								buffer.replaceSubrange(0..<range.upperBound, with: Data())
								if let line = String(data: slice, encoding: .utf8) {
										block(line)
								}
						}
						chunk = output.availableData
				}
				proc.terminate()
		}
}
struct Log : Hashable, Equatable {
		let subsystem:String, category:String
}
func find_logs(url: URL) -> [Log]? {
		let literal = "literal pool for: \"", hold = "HOLD"
		var ring = [hold, hold], idx = false, logs = Set<Log>()
		Process.launchedForLines(url: URL(fileURLWithPath: "/usr/bin/otool", isDirectory: false), args: ["-tV", url.path], block: { (line) in
				if let range = line.range(of: literal) {
						let frag = line[range.upperBound..<line.index(before: line.endIndex)]
						ring[idx ? 1 : 0] = String(frag)
						idx = !idx
				}
				else if line.range(of: "_os_log_create", options: .literal) != nil {
						let sub = ring[idx ? 1 : 0], cat = ring[idx ? 0 : 1]
						if sub != hold && cat != hold && sub.range(of: ".", options: .literal) != nil {
								logs.insert(Log(subsystem: sub, category: cat))
						}
						ring = [hold, hold]
				}
		})
		return logs.isEmpty ? nil : Array(logs)
}
func check_mach(url: URL) -> Bool {
		guard let handle = try? FileHandle(forReadingFrom: url) else {
				return false
		}
		let size = MemoryLayout.size(ofValue: MH_MAGIC), magic = handle.readData(ofLength: size)
		try? handle.close()
		return magic.count == size && [MH_MAGIC, MH_MAGIC_64, FAT_CIGAM, FAT_CIGAM_64].contains(magic.withUnsafeBytes({ $0.load(as: UInt32.self) }))
}
func enumerate(url: URL, block: (URL, URLFileResourceType) -> Void) {
		guard let type = try? url.resourceValues(forKeys: [.fileResourceTypeKey]).fileResourceType else {
				return
		}
		block(url, type)
		if (type == .directory) {
				_ = (try? FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys: [.fileResourceTypeKey], options: []))?.map({ enumerate(url: $0, block: block) })
		}
}
let args = ProcessInfo().arguments
guard let base = args.count > 1 ? URL(fileURLWithPath: args[1]) : nil else {
		print("Specify exactly one argument, the path to search")
		exit(1)
}
enumerate(url: base) { (url, type) in
		autoreleasepool {
				if type == .regular && check_mach(url: url), let logs = find_logs(url: url) {
						print("Found binary \(url.path)")
						_ = logs.map({ print("Subsystem: \($0.subsystem) Category: \($0.category)") })
				}
		}
}
Post marked as unsolved
147
Views
When my app contains a lot of logging I find the Xcode output console becomes overwhelmed with logging messages and it becomes easy to miss something important and/or difficult to focus on a particular area. Is there a way to filter by a particular category as well as by type?
Post marked as unsolved
268
Views
The new logging system looks nice, but the video didn't discuss how to get those logs from production devices. It only covered getting them during testing.
If a customer contacts support from inside my app, I need to get a copy of the logs from that app/user. I currently am writing my logs to a text file, and then attaching that when they contact support. I realize that isn't ideal from a performance perspective.
import os
let logger = Logger(subsystem: "com.example.Fruta", category: "giftcards")
logger.log("Started a task")
Post marked as solved
223
Views
I noticed there is logging API in this session which doesn't seem to be public right now:
logger.log("\(offerID, align: .left(columns: 10), privacy: .public)")
OSLog has no log method (https://developer.apple.com/documentation/oslog) and log isn't part of the current SwiftLog API. (https://github.com/apple/swift-log)
Is there another new API I missed or is this going to be coming in a future version?
Post marked as unsolved
132
Views
Date/Time: 2020-06-21 09:58:48.8290 -0700
Launch Time: 2020-06-21 09:58:25.9986 -0700
OS Version: iPhone OS 13.5.1 (17F80)
Release Type: User
Baseband Version: n/a
Report Version: 104
Exception Type: EXCCRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXCCORPSENOTIFY
Triggered by Thread: 0
Last Exception Backtrace:
(0x19eb3f794 0x19e861bcc 0x19ea35b98 0x1a2556c74 0x1a2143e94 0x1a21440b4 0x1a20e0cac 0x1a259ddd0 0x104f8b37c 0x104fffb60 0x104ff7070 0x1a2877c40 0x1a2143e94 0x1a20e0cac 0x1a287bbbc 0x1a2143e94 0x1a21440b4 0x1a20e0cac 0x1a2876cd8 0x1a2879858 0x1a2d4b84c 0x104fcda34 0x104f944d8 0x10519f030 0x1051a2f40 0x10517cad8 0x19e8049a8 0x19e805524 0x19e7b75b4 0x19eabd7fc 0x19eab86d0 0x19eab7ce8 0x1a8c0238c 0x1a2be6444 0x104f7012c 0x19e93f8f0)
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystemkernel.dylib 0x000000019e934d88 0x19e90f000 + 155016
1 libsystempthread.dylib 0x000000019e84d1e8 0x19e84b000 + 8680
2 libsystemc.dylib 0x000000019e7a0934 0x19e72e000 + 469300
3 libc++abi.dylib 0x000000019e908cc0 0x19e8f6000 + 76992
4 libc++abi.dylib 0x000000019e8fae10 0x19e8f6000 + 19984
5 libobjc.A.dylib 0x000000019e861e80 0x19e85c000 + 24192
6 libc++abi.dylib 0x000000019e90814c 0x19e8f6000 + 74060
7 libc++abi.dylib 0x000000019e9080e4 0x19e8f6000 + 73956
8 libdispatch.dylib 0x000000019e805538 0x19e7aa000 + 374072
9 libdispatch.dylib 0x000000019e7b75b4 0x19e7aa000 + 54708
10 CoreFoundation 0x000000019eabd7fc 0x19ea15000 + 690172
11 CoreFoundation 0x000000019eab86d0 0x19ea15000 + 669392
12 CoreFoundation 0x000000019eab7ce8 0x19ea15000 + 666856
13 GraphicsServices 0x00000001a8c0238c 0x1a8bff000 + 13196
14 UIKitCore 0x00000001a2be6444 0x1a21b8000 + 10675268
15 AppyHome 0x0000000104f7012c 0x104f64000 + 49452
16 libdyld.dylib 0x000000019e93f8f0 0x19e93e000 + 6384
Thread 1:
0 libsystempthread.dylib 0x000000019e859738 0x19e84b000 + 59192
Thread 2:
0 libsystempthread.dylib 0x000000019e859738 0x19e84b000 + 59192
Thread 3 name: com.apple.uikit.eventfetch-thread
Thread 3:
0 libsystemkernel.dylib 0x000000019e913198 0x19e90f000 + 16792
1 libsystemkernel.dylib 0x000000019e91260c 0x19e90f000 + 13836
2 CoreFoundation 0x000000019eabd468 0x19ea15000 + 689256
3 CoreFoundation 0x000000019eab849c 0x19ea15000 + 668828
4 CoreFoundation 0x000000019eab7ce8 0x19ea15000 + 666856
5 Foundation 0x000000019edfb01c 0x19edf3000 + 32796
6 Foundation 0x000000019edfaefc 0x19edf3000 + 32508
7 UIKitCore 0x00000001a2c895dc 0x1a21b8000 + 11343324
8 Foundation 0x000000019ef29e20 0x19edf3000 + 1273376
9 libsystempthread.dylib 0x000000019e855d98 0x19e84b000 + 44440
10 libsystempthread.dylib 0x000000019e85974c 0x19e84b000 + 59212
Thread 4:
0 libsystempthread.dylib 0x000000019e859738 0x19e84b000 + 59192
Thread 5:
0 libsystempthread.dylib 0x000000019e859738 0x19e84b000 + 59192
Thread 6:
0 libsystempthread.dylib 0x000000019e859738 0x19e84b000 + 59192
Thread 7:
0 libsystempthread.dylib 0x000000019e859738 0x19e84b000 + 59192
Thread 8 name: com.apple.NSURLConnectionLoader
Thread 8:
0 libsystemkernel.dylib 0x000000019e913198 0x19e90f000 + 16792
1 libsystemkernel.dylib 0x000000019e91260c 0x19e90f000 + 13836
2 CoreFoundation 0x000000019eabd468 0x19ea15000 + 689256
3 CoreFoundation 0x000000019eab849c 0x19ea15000 + 668828
4 CoreFoundation 0x000000019eab7ce8 0x19ea15000 + 666856
5 CFNetwork 0x00000001a1d78894 0x1a1d77000 + 6292
6 Foundation 0x000000019ef29e20 0x19edf3000 + 1273376
7 libsystempthread.dylib 0x000000019e855d98 0x19e84b000 + 44440
8 libsystempthread.dylib 0x000000019e85974c 0x19e84b000 + 59212
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000000000000000 x1: 0x0000000000000000 x2: 0x0000000000000000 x3: 0x0000000000000000
x4: 0x000000019e90bf29 x5: 0x000000016ae9a670 x6: 0x000000000000006e x7: 0xffffffffffffffec
x8: 0x000000010541d840 x9: 0xe640c3b37bc4582a x10: 0x000000019e84d160 x11: 0x000000000000000b
x12: 0x00000001d85a6080 x13: 0x0000000000000001 x14: 0x0000000000000010 x15: 0x0000000000000045
x16: 0x0000000000000148 x17: 0x0000000000000000 x18: 0x0000000000000000 x19: 0x0000000000000006
x20: 0x0000000000000407 x21: 0x000000016ae9a670 x22: 0x000000010541d920 x23: 0x0000000000000000
x24: 0x0000000000000114 x25: 0x0000000283c60080 x26: 0x000000010541d920 x27: 0x00000000000020ff
x28: 0x0000000002ffffff fp: 0x000000016ae9a5d0 lr: 0x000000019e84d1e8
sp: 0x000000016ae9a5b0 pc: 0x000000019e934d88 cpsr: 0x40000000
esr: 0x56000080 Address size fault
Crash log - https://developer.apple.com/forums/content/attachment/17576994-cf79-4cd4-92f4-29a97a856be5