-
-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add LogCat integration to Android via an EventProcessor #2926
Conversation
…listically MAUI can't target version 23 anway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for adding this!
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome folks! thanks a lot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
… 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome! Thanks Daniel!
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
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.