~eliasnaur/gio#84: 
android logs should use the configured appid

Right now, on Android, stdout and stderr are recorded as log messages. That's good, because it helps with debugging.

However, the tag is simply "gio". I think it should be something more unique. How about the app ID set via gogio -appid?

Here's a concrete use case: I'm writing end-to-end tests for Android, and filtering by the tag "gio" isn't unique at all. If another gio app happens to be running on the same device or emulator, I might be in trouble.

Status
RESOLVED FIXED
Submitter
~mvdan
Assigned to
No-one
Submitted
6 months ago
Updated
2 months ago
Labels
No labels applied.

~eliasnaur 6 months ago

On Sat Jan 25, 2020 at 4:09 PM, ~mvdan wrote:

Right now, on Android, stdout and stderr are recorded as log messages. That's good, because it helps with debugging.

However, the tag is simply "gio". I think it should be something more unique. How about the app ID set via gogio -appid?

Sounds good to me.

~mvdan 6 months ago

Cool. I'll see if I can get a working patch once the android e2e test is merged.

~mvdan 3 months ago

I've had a brief look at this today, but I'm a bit stuck. The app ID is only provided as a flag to the build tool, so it's not directly accessible to log_android.go statically.

I guess we could fetch the app ID via the native libraries, but I haven't found a way to do that. And, if there's a way, we wouldn't want to do that work at every log call. I guess we could use a sync.Once?

Pointers welcome.

~eliasnaur 3 months ago

gogio uses the -X linker flag to supply fake os.Args to mobile apps:

https://git.sr.ht/~eliasnaur/gio/tree/master/cmd/gogio/main.go#L116

perhaps something similar could be done to set the log tag?

~mvdan 3 months ago

Ah, that's a good idea. Some follow-up assumptions for your input:

  • I think we should set this always, for consistency.
  • I think an "AppID" variable is probably the right level of portability. It can default to "gio" or something like that on platforms that don't have such a concept, like Linux. Those platforms wouldn't use the variable for now.
  • I think placing it in app/internal/log is probably OK for now, since we want it somewhere low level and hidden. We could move it somewhere a bit more appropriate in the future if needed, like app/internal/cfg.

~mvdan 3 months ago

I think we should set this always, for consistency.

To clarify, what I mean here is that -appid should add the -X liner flag, regardless of the platform we're building for.

~eliasnaur 3 months ago

On Sun May 3, 2020 at 4:17 PM, ~mvdan wrote:

Ah, that's a good idea. Some follow-up assumptions for your input:

* I think we should set this always, for consistency.

  • I think an "AppID" variable is probably the right level of portability. It can default to "gio" or something like that on platforms that don't have such a concept, like Linux. Those platforms wouldn't use the variable for now.

Do you see a need for AppID to be exported? If not, let's keep it unexported as an implementation detail between gogio and the app/internal/log package.

~mvdan 2 months ago

I did this in e97adeedd9186530b84a40ebd0ebb7af66eb0e07.

~eliasnaur I thought the "fixes" comment lines would work in sourcehut automagically, so I guess they don't.

~mvdan REPORTED FIXED 2 months ago

Register here or Log in to comment, or comment via email.