Skip to content

[Event Detail]: Attachment preview for Android logcat output #61005

Closed

Description

@bruno-garcia

Events from Android can send device logcat logs as attachments.

The current preview format shows it as standard text. We'd like to be able to see the logs in a more user friendly way.
For example, with process/ priority and timestamp filter, coloring, etc.

For example, the logcat window inside Android Studio:

image

Solution brainstorming

Add to the current handlers one called text/logcat:

const getInlineAttachmentRenderer = (attachment: IssueAttachment) => {
switch (attachment.mimetype) {
case 'text/plain':
return attachment.size > 0 ? LogFileViewer : undefined;
case 'text/json':
case 'text/x-json':
case 'application/json':
if (attachment.name === 'rrweb.json' || attachment.name.startsWith('rrweb-')) {
return RRWebJsonViewer;
}
return JsonViewer;
case 'image/jpeg':
case 'image/png':
case 'image/gif':
return ImageViewer;
default:
return undefined;
}
};

Use an npm library that parses the output to display the preview with field on top.

More context on this PR/thread: getsentry/sentry-dotnet#2926 (comment)

Activity

  1. changed the title [-][Event Detail]: Attachment preview for logcat output[/-] [+][Event Detail]: Attachment preview for Android logcat output[/+] on Dec 1, 2023
  2. kanadaj commented on Dec 2, 2023

    @kanadaj

    Here is a sample log file:

    --------- beginning of crash
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: FATAL EXCEPTION: main
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: Process: com.NotYetMedia.RoyalRoad, PID: 12112
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.NotYetMedia.RoyalRoad/crc64d22d936ca88f8d15.MainActivity}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3433)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3607)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2068)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:106)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:223)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7680)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at java.lang.reflect.Method.invokeNative(Native Method)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Method.java:423)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: Caused by: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at androidx.fragment.app.FragmentManager.checkStateLoss(SourceFile:12)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at androidx.fragment.app.FragmentManager.enqueueAction(SourceFile:27)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at androidx.fragment.app.BackStackRecord.commitInternal(SourceFile:70)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at androidx.fragment.app.BackStackRecord.commit(SourceFile:2)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at crc64d22d936ca88f8d15.MainActivity.n_onCreate(Native Method)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at crc64d22d936ca88f8d15.MainActivity.onCreate(SourceFile:1)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at android.app.Activity.performCreate(Activity.java:7994)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at android.app.Activity.performCreate(Activity.java:7978)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1548)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3406)
    12-02 00:38:12.756 12112 12112 E AndroidRuntime: 	... 12 more
    --------- beginning of main
    12-02 00:43:48.016 13292 13292 I SentryExecutorS: type=1400 audit(0.0:1908): avc: denied { write } for name="deleted" dev="vda11" ino=10733 scontext=u:r:untrusted_app:s0:c168,c256,c512,c768 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=1 app=com.NotYetMedia.RoyalRoad
    12-02 00:43:48.016 13292 13292 I SentryExecutorS: type=1400 audit(0.0:1909): avc: denied { add_name } for name="breadcrumbs.json" dev="vda11" ino=6146 scontext=u:r:untrusted_app:s0:c168,c256,c512,c768 tcontext=u:object_r:shell_data_file:s0 tclass=dir permissive=1 app=com.NotYetMedia.RoyalRoad
    12-02 00:43:48.239 13292 13292 I Media.RoyalRoa: Explicit concurrent copying GC freed 1829(143KB) AllocSpace objects, 4(80KB) LOS objects, 24% free, 5016KB/6688KB, paused 40us total 22.044ms
    12-02 00:43:48.370 13292 13292 I Media.RoyalRoa: Explicit concurrent copying GC freed 680(58KB) AllocSpace objects, 0(0B) LOS objects, 24% free, 4973KB/6631KB, paused 36us total 23.083ms

    So the standard format is basically

    {MM}-{DD} {HH:mm:ss.ttt} {ProcessID} {ThreadID} {Level} {Tag}: {Message}
    

    and multi-line messages have this header on each line. Some lines may begin with a series of hyphens to signify a separator, these should probably be unparsed. Levels are:

    A - Assert
    V - Verbose
    D - Debug
    I - Info
    W - Warning
    E - Error
    

    Managed C# stack traces from .NET Android follow mostly the same format as Java stacktraces with the exception that they have the arguments instead of the file and line number:

    Java:

    12-02 00:43:49.770 13292 13292 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.NotYetMedia.RoyalRoad/crc64d22d936ca88f8d15.MainActivity}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
    12-02 00:43:49.770 13292 13292 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3433)
    12-02 00:43:49.770 13292 13292 E AndroidRuntime: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3607)
    12-02 00:43:49.770 13292 13292 E AndroidRuntime: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85)
    12-02 00:43:49.770 13292 13292 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)

    C#:

    12-02 00:43:49.864 13292 13292 I MonoDroid: Java.Lang.RuntimeException: Unable to start activity ComponentInfo{com.NotYetMedia.RoyalRoad/crc64d22d936ca88f8d15.MainActivity}: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState
    12-02 00:43:49.864 13292 13292 I MonoDroid:  ---> Java.Lang.IllegalStateException: Can not perform this action after onSaveInstanceState
    12-02 00:43:49.864 13292 13292 I MonoDroid:    at Java.Interop.JniEnvironment.InstanceMethods.CallIntMethod(JniObjectReference , JniMethodInfo , JniArgumentValue* )
    12-02 00:43:49.865 13292 13292 I MonoDroid:    at Java.Interop.JniPeerMembers.JniInstanceMethods.InvokeAbstractInt32Method(String , IJavaPeerable , JniArgumentValue* )
    12-02 00:43:49.865 13292 13292 I MonoDroid:    at AndroidX.Fragment.App.FragmentTransactionInvoker.Commit()
    12-02 00:43:49.865 13292 13292 I MonoDroid:    at Microsoft.Maui.Platform.NavigationRootManager.SetContentView(IView view)

    so it's also possible to highlight lines with stacktrace lines via

        at {Namespace}.{Class}({Details})
    

    where {Details} is {Filename}:{Line} for Java stacktraces and a comma separated list of {Type}[ {ParamName}] args with optional ParamName for C#. I assume the same can be done for React Native as well.

  3. moved this to Waiting for: Product Owner in GitHub Issues with 👀on Dec 2, 2023
  4. getsantry commented on Dec 5, 2023

    @getsantry
    Contributor

    Routing to @getsentry/product-owners-issues for triage ⏲️

  5. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀on Dec 5, 2023
  6. bruno-garcia commented on Oct 20, 2024

    @bruno-garcia
    MemberAuthor

    Since this issue will celebrate 1 year birthday, I raise a simpler one so we can at least see them as flat file:

  7. bruno-garcia commented on Aug 9, 2025

    @bruno-garcia
    MemberAuthor

    Since we're adding logs as a first class citizen, I don't think this is worth the effort.

  8. locked and limited conversation to collaborators on Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions