kean / Pulse

Network logger for Apple platforms
https://pulselogger.com
MIT License
6.25k stars 296 forks source link

WatchKit remote logging #200

Closed ptxmac closed 1 year ago

ptxmac commented 1 year ago

The configuration for remote logging currently exists in the UI for Apple Watch but doesn't work.

From what I could gather Pulse is using low-level networking to stream logs. Unfortunately, Apple Watch doesn't support this (with a few very specific exceptions). See TN3135

There doesn't seem to be any easy workaround, the only supported ways of doing networking on the watch is through HTTP or Watch Connectivity (i.e. communicating with a companion iOS app)

Since there's already a "Send to iPhone" feature, maybe some of that logic could be reused to make a logger that would stream to the iPhone and the iOS receiver could re-emit the logs on its store.

(Note: it does work in the simulator, but that's a bug)

kean commented 1 year ago

Unfortunately, Apple Watch doesn't support this (with a few very specific exceptions). See TN3135

That's a shame. I never tested it on a physical device, and, as you pointed out, it works in a simulator, so I left it there. It's worth keeping it only on a simulator and showing an error when running on a device.

Since there's already a "Send to iPhone" feature, maybe some of that logic could be reused to make a logger that would stream to the iPhone and the iOS receiver could re-emit the logs on its store.

That would be nice. I thought about making an iPhone your primary way to interact with the watchOS console. Still, it would've required significant time investment, and, as it looks like, barely anyone uses it on the watch – nobody raised this issue before.

There is a new "Open on Mac" feature in Pulse 14.0.0-beta.2 that allows you to quickly view individual messages or tasks on a Mac. I think it could be implemented relatively easily, and unlike streaming won't affect battery life, which is important to take into account.

ptxmac commented 1 year ago

The "Open on Mac" sounds interesting, but that still require the messages from the watch to somehow end up on the mac - there's no support for WCSession on MacOS, so the data needs to go through iOS first

kean commented 1 year ago

I was thinking "Open on iPhone" as a middle-ground solution. But I'm not sure what's the best API to implement it.

ptxmac commented 1 year ago

I guess that's very close to how the current "Send to iPhone" buttons work now? (minus #201)

Regarding API there are not a lot of options 😄 Basically WCSession is all there is

kean commented 1 year ago

By "Open on iPhone", I was referring to a feature where you to open individual tasks (quickly). But now that I'm thinking about it, it's probably not going to be as useful on watchOS. You kind of just want to get the logs off the device quickly.

I'm not sure I want to tackle streaming using WCSession 😅 But fixing WCSession support and adding ShareLink support (for sharing to Mac directly) is a must.

ptxmac commented 1 year ago

I'm not sure I want to tackle streaming using WCSession

Yeah, don't blame you, WCSession is frustrating to work with 😄 I might look into it if I end up using Pulse in my project (still evaluating it)

kean commented 1 year ago

That would be nice. I've built most of the infra needed for the watchOS version, but it is clearly in need of some contributors who use it on a daily basis.

kean commented 1 year ago

Fixed in 4.0.0-beta.3.