Repository navigation
Add LogCat integration to Android via an EventProcessor - #2926
Conversation
…listically MAUI can't target version 23 anway
bruno-garcia
left a comment
There was a problem hiding this comment.
Thanks a lot for adding this!
Co-authored-by: Bruno Garcia <[email protected]>
Co-authored-by: Bruno Garcia <[email protected]>
Co-authored-by: Bruno Garcia <[email protected]>
Co-authored-by: Bruno Garcia <[email protected]>
Co-authored-by: Bruno Garcia <[email protected]>
bruno-garcia
left a comment
There was a problem hiding this comment.
I think it looks great!
Could you add this to the sample, please?
We at least should get some manual testing done there and then integration tests (no point in unit testing this I guess?)
| process.InputStream.CopyTo(output); | ||
| process.WaitFor(); | ||
|
|
||
| hint.AddAttachment(filesDir!.Path + "/sentry_logcat.txt", AttachmentType.Default, "text/logcat"); |
There was a problem hiding this comment.
@matejminar we're making up a new mime/type here, is that OK? The goal is to have a customer preview in Sentry that understand logcat and is able to filter by the different columns or highlight stuff etc, wdty?
@romtsn would we want that on Android in general?
There was a problem hiding this comment.
@bruno-garcia yes, you'll need to add logcat into this switch to map it to an existing viewer:
https://github.com/getsentry/sentry/blob/d4f5584da02f71f4c2a1a00792b9558c22df61db/static/app/components/events/eventAttachments.tsx#L38-L56
if you want a fancy logcat-specific viewer, you can take an inspo from one of the existing ones there
There was a problem hiding this comment.
@bruno-garcia yeah, so far we opted for bytecode manipulation and sending breadcrumbs - this works for the app and libraries logcat calls, but not the system ones. Also it supports all Android versions, while this approach is from API 23 and above.
But generally, I think this would be nice to have, especially when we bump min sdk to 21 or 24 in the future. Should probably be opt-in by default though
There was a problem hiding this comment.
Awesome folks! thanks a lot
Co-authored-by: Bruno Garcia <[email protected]>
Co-authored-by: Bruno Garcia <[email protected]>
Co-authored-by: Bruno Garcia <[email protected]>
… the FilesDir, generate the file name dynamically
Yeah there is really nothing to unit test, you need a running Android device or emulator with logcat to test this one. |
bruno-garcia
left a comment
There was a problem hiding this comment.
This is awesome! Thanks Daniel!
Co-authored-by: Bruno Garcia <[email protected]>
Co-authored-by: Bruno Garcia <[email protected]>
|
PR adding it to Android: getsentry/sentry-java#2620 |
That one uses breadcrumbs though... And while that's possible, imho logcat outputs way too much noise for breadcrumbs to be particularly useful (sometimes you need several hundred log messages from logcat to find what you need). Afaik it also relies on using Gradle to replace |
|
Thanks again for adding this! Lemme figure out what's up with the device tests.. |
Some internal chatter came to the conclusion we should:
|
|
Sure, lemme do that. |
It is possible to fetch LogCat logs using
Runtime.Exec()per the following comment: getsentry/sentry-java#1620 (comment)This SentryEventProcessor automatically grabs the LogCat logs on error (configurable to only log on unhandled errors, all errors or all events) and attaches it to the SentryEvent as a file attachment.