This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 32
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mike-burns
added a commit
to mike-burns/sentry-android
that referenced
this pull request
Mar 20, 2020
A common pattern is to "log" exceptions and messages to Sentry. It's a convenient place to collect programmer errors: situations that absolutely should not happen according to the business logic, but happen anyway because of constraints not caught by the type system or test suite. In debug builds we often have Sentry disabled because we don't want to clutter it with all the ANRs and simple mistakes of development life. This can mean that exceptions we are "logging" to Sentry get missed. Instead we can use a `StdoutTransport`, logging them to the stdout log: ```kotlin SentryAndroid.init(this) { options -> if (BuildConfig.DEBUG) { options.setTransport(StdoutTransport(options.serializer)) } } ``` This will log a message like so: ``` 03-20 18:32:47.623 17385-17436/io.sentry.sample I/System.out: {"breadcrumbs":[],"contexts":{"app":{"app_build":"1","app_identifier":"io.sentry.sample","app_version":"1.0"},"os":{"build":"sdk_google_phone_x86-userdebug 6.0 MASTER 5525988 test-keys","kernel_version":"Linux version 3.10.0+ (lfy@lfy0.mtv.corp.google.com) (gcc version 4.9 20140827 (prerelease) (GCC) ) getsentry#1 SMP PREEMPT Wed Feb 22 08:53:42 PST 2017","name":"Android","rooted":true,"version":"6.0"},"device":{"arch":"x86","archs":["x86"],"battery_level":100.0,"boot_time":"2020-03-17T19:59:39Z","brand":"Android","charging":true,"external_free_storage":534726656,"external_storage_size":534761472,"family":"Android","free_memory":1231368192,"free_storage":346652672,"id":"7db661d77068d2d8","language":"en_US","low_memory":false,"manufacturer":"unknown","memory_size":1588129792,"model":"Android SDK built for x86","model_id":"MASTER","name":"Android SDK built for x86","online":true,"orientation":"portrait","screen_density":3.0,"screen_dpi":480,"screen_height_pixels":1776,"screen_resolution":"1776x1080","screen_width_pixels":1080,"simulator":true,"storage_size":812531712,"timezone":"GMT"}},"dist":"1","event_id":"bb32506411d94d40b042a8a3862f6d43","exception":{"values":[{"module":"java.lang","stacktrace":{"frames":[{"native":false,"filename":"ZygoteInit.java","function":"main","in_app":false,"lineno":616,"module":"com.android.internal.os.ZygoteInit"},{"native":false,"filename":"ZygoteInit.java","function":"run","in_app":false,"lineno":726,"module":"com.android.internal.os.ZygoteInit$MethodAndArgsCaller"},{"native":true,"filename":"Method.java","function":"invoke","in_app":false,"module":"java.lang.reflect.Method"},{"native":false,"filename":"ActivityThread.java","function":"main","in_app":false,"lineno":5417,"module":"android.app.ActivityThread"},{"native":false,"filename":"Looper.java","function":"loop","in_app":false,"lineno":148,"module":"android.os.Looper"},{"native":false,"filename":"Handler.java","function":"dispatchMessage","in_app":false,"lineno":95,"module":"android.os.Handler"},{"native":false,"filename":"Handler.java","function":"handleCallback","in_app":false,"lineno":739,"module":"android.os.Handler"},{"native":false,"filename":"View.java","function":"run","in_app":false,"lineno":21147,"module":"android.view.View$PerformClick"},{"native":false,"filename":"View.java","function":"performClick","in_app":false,"lineno":5198,"module":"android.view.View"},{"native":false,"filename":"lambda","function":"onClick","in_app":true,"module":"io.sentry.sample.-$$Lambda$MainActivity$tVGPRGxxb8SivUa5SKhzp6BuXOI"},{"native":false,"filename":"MainActivity.java","function":"lambda$onCreate$2","in_app":true,"lineno":32,"module":"io.sentry.sample.MainActivity"}]},"thread_id":1,"type":"Exception","value":"java.lang.Exception: java.lang.Exception: Some exception."},{"module":"java.lang","stacktrace":{"frames":[{"native":false,"filename":"ZygoteInit.java","function":"main","in_app":false,"lineno":616,"module":"com.android.internal.os.ZygoteInit"},{"native":false,"filename":"ZygoteInit.java","function":"run","in_app":false,"lineno":726,"module":"com.android.internal.os.ZygoteInit$MethodAndArgsCaller"},{"native":true,"filename":"Method.java","function":"invoke","in_app":false,"module":"java.lang.reflect.Method"},{"native":false,"filename":"ActivityThread.java","function":"main","in_app":false,"lineno":5417,"module":"android.app.ActivityThread"},{"native":false,"filename":"Looper.java","function":"loop","in_app":false,"lineno":148,"module":"android.os.Looper"},{"native":false,"filename":"Handler.java","function":"dispatchMessage","in_app":false,"lineno":95,"module":"android.os.Handler"},{"native":false,"filename":"Handler.java","function":"handleCallback","in_app":false,"lineno":739,"module":"android.os.Handler"},{"native":false,"filename":"View.java","function":"run","in_app":false,"lineno":21147,"module":"android.view.View$PerformClick"},{"native":false,"filename":"View.java","function":"performClick","in_app":false,"lineno":5198,"module":"android.view.View"},{"native":false,"filename":"lambda","function":"onClick"," ``` Closes getsentry#298, getsentry#296. Thanks to marandaneto for the initial implementation.
mike-burns
added a commit
to mike-burns/sentry-android
that referenced
this pull request
Mar 20, 2020
A common pattern is to "log" exceptions and messages to Sentry. It's a convenient place to collect programmer errors: situations that absolutely should not happen according to the business logic, but happen anyway because of constraints not caught by the type system or test suite. In debug builds we often have Sentry disabled because we don't want to clutter it with all the ANRs and simple mistakes of development life. This can mean that exceptions we are "logging" to Sentry get missed. Instead we can use a `StdoutTransport`, logging them to the stdout log: ```kotlin SentryAndroid.init(this) { options -> if (BuildConfig.DEBUG) { options.setTransport(StdoutTransport(options.serializer)) } } ``` This will log a message like so: ``` 03-20 18:32:47.623 17385-17436/io.sentry.sample I/System.out: {"breadcrumbs":[],"contexts":{"app":{"app_build":"1","app_identifier":"io.sentry.sample","app_version":"1.0"},"os":{"build":"sdk_google_phone_x86-userdebug 6.0 MASTER 5525988 test-keys","kernel_version":"Linux version 3.10.0+ (lfy@lfy0.mtv.corp.google.com) (gcc version 4.9 20140827 (prerelease) (GCC) ) getsentry#1 SMP PREEMPT Wed Feb 22 08:53:42 PST 2017","name":"Android","rooted":true,"version":"6.0"},"device":{"arch":"x86","archs":["x86"],"battery_level":100.0,"boot_time":"2020-03-17T19:59:39Z","brand":"Android","charging":true,"external_free_storage":534726656,"external_storage_size":534761472,"family":"Android","free_memory":1231368192,"free_storage":346652672,"id":"7db661d77068d2d8","language":"en_US","low_memory":false,"manufacturer":"unknown","memory_size":1588129792,"model":"Android SDK built for x86","model_id":"MASTER","name":"Android SDK built for x86","online":true,"orientation":"portrait","screen_density":3.0,"screen_dpi":480,"screen_height_pixels":1776,"screen_resolution":"1776x1080","screen_width_pixels":1080,"simulator":true,"storage_size":812531712,"timezone":"GMT"}},"dist":"1","event_id":"bb32506411d94d40b042a8a3862f6d43","exception":{"values":[{"module":"java.lang","stacktrace":{"frames":[{"native":false,"filename":"ZygoteInit.java","function":"main","in_app":false,"lineno":616,"module":"com.android.internal.os.ZygoteInit"},{"native":false,"filename":"ZygoteInit.java","function":"run","in_app":false,"lineno":726,"module":"com.android.internal.os.ZygoteInit$MethodAndArgsCaller"},{"native":true,"filename":"Method.java","function":"invoke","in_app":false,"module":"java.lang.reflect.Method"},{"native":false,"filename":"ActivityThread.java","function":"main","in_app":false,"lineno":5417,"module":"android.app.ActivityThread"},{"native":false,"filename":"Looper.java","function":"loop","in_app":false,"lineno":148,"module":"android.os.Looper"},{"native":false,"filename":"Handler.java","function":"dispatchMessage","in_app":false,"lineno":95,"module":"android.os.Handler"},{"native":false,"filename":"Handler.java","function":"handleCallback","in_app":false,"lineno":739,"module":"android.os.Handler"},{"native":false,"filename":"View.java","function":"run","in_app":false,"lineno":21147,"module":"android.view.View$PerformClick"},{"native":false,"filename":"View.java","function":"performClick","in_app":false,"lineno":5198,"module":"android.view.View"},{"native":false,"filename":"lambda","function":"onClick","in_app":true,"module":"io.sentry.sample.-$$Lambda$MainActivity$tVGPRGxxb8SivUa5SKhzp6BuXOI"},{"native":false,"filename":"MainActivity.java","function":"lambda$onCreate$2","in_app":true,"lineno":32,"module":"io.sentry.sample.MainActivity"}]},"thread_id":1,"type":"Exception","value":"java.lang.Exception: java.lang.Exception: Some exception."},{"module":"java.lang","stacktrace":{"frames":[{"native":false,"filename":"ZygoteInit.java","function":"main","in_app":false,"lineno":616,"module":"com.android.internal.os.ZygoteInit"},{"native":false,"filename":"ZygoteInit.java","function":"run","in_app":false,"lineno":726,"module":"com.android.internal.os.ZygoteInit$MethodAndArgsCaller"},{"native":true,"filename":"Method.java","function":"invoke","in_app":false,"module":"java.lang.reflect.Method"},{"native":false,"filename":"ActivityThread.java","function":"main","in_app":false,"lineno":5417,"module":"android.app.ActivityThread"},{"native":false,"filename":"Looper.java","function":"loop","in_app":false,"lineno":148,"module":"android.os.Looper"},{"native":false,"filename":"Handler.java","function":"dispatchMessage","in_app":false,"lineno":95,"module":"android.os.Handler"},{"native":false,"filename":"Handler.java","function":"handleCallback","in_app":false,"lineno":739,"module":"android.os.Handler"},{"native":false,"filename":"View.java","function":"run","in_app":false,"lineno":21147,"module":"android.view.View$PerformClick"},{"native":false,"filename":"View.java","function":"performClick","in_app":false,"lineno":5198,"module":"android.view.View"},{"native":false,"filename":"lambda","function":"onClick"," ``` Closes getsentry#298, getsentry#296. Thanks to marandaneto for the initial implementation.
in favor of #310 |
mike-burns
added a commit
to mike-burns/sentry-android
that referenced
this pull request
Mar 20, 2020
A common pattern is to "log" exceptions and messages to Sentry. It's a convenient place to collect programmer errors: situations that absolutely should not happen according to the business logic, but happen anyway because of constraints not caught by the type system or test suite. In debug builds we often have Sentry disabled because we don't want to clutter it with all the ANRs and simple mistakes of development life. This can mean that exceptions we are "logging" to Sentry get missed. Instead we can use a `StdoutTransport`, logging them to the stdout log: ```kotlin SentryAndroid.init(this) { options -> if (BuildConfig.DEBUG) { options.setTransport(StdoutTransport(options.serializer)) } } ``` This will log a message like so: ``` 03-20 18:32:47.623 17385-17436/io.sentry.sample I/System.out: {"breadcrumbs":[],"contexts":{"app":{"app_build":"1","app_identifier":"io.sentry.sample","app_version":"1.0"},"os":{"build":"sdk_google_phone_x86-userdebug 6.0 MASTER 5525988 test-keys","kernel_version":"Linux version 3.10.0+ (lfy@lfy0.mtv.corp.google.com) (gcc version 4.9 20140827 (prerelease) (GCC) ) getsentry#1 SMP PREEMPT Wed Feb 22 08:53:42 PST 2017","name":"Android","rooted":true,"version":"6.0"},"device":{"arch":"x86","archs":["x86"],"battery_level":100.0,"boot_time":"2020-03-17T19:59:39Z","brand":"Android","charging":true,"external_free_storage":534726656,"external_storage_size":534761472,"family":"Android","free_memory":1231368192,"free_storage":346652672,"id":"7db661d77068d2d8","language":"en_US","low_memory":false,"manufacturer":"unknown","memory_size":1588129792,"model":"Android SDK built for x86","model_id":"MASTER","name":"Android SDK built for x86","online":true,"orientation":"portrait","screen_density":3.0,"screen_dpi":480,"screen_height_pixels":1776,"screen_resolution":"1776x1080","screen_width_pixels":1080,"simulator":true,"storage_size":812531712,"timezone":"GMT"}},"dist":"1","event_id":"bb32506411d94d40b042a8a3862f6d43","exception":{"values":[{"module":"java.lang","stacktrace":{"frames":[{"native":false,"filename":"ZygoteInit.java","function":"main","in_app":false,"lineno":616,"module":"com.android.internal.os.ZygoteInit"},{"native":false,"filename":"ZygoteInit.java","function":"run","in_app":false,"lineno":726,"module":"com.android.internal.os.ZygoteInit$MethodAndArgsCaller"},{"native":true,"filename":"Method.java","function":"invoke","in_app":false,"module":"java.lang.reflect.Method"},{"native":false,"filename":"ActivityThread.java","function":"main","in_app":false,"lineno":5417,"module":"android.app.ActivityThread"},{"native":false,"filename":"Looper.java","function":"loop","in_app":false,"lineno":148,"module":"android.os.Looper"},{"native":false,"filename":"Handler.java","function":"dispatchMessage","in_app":false,"lineno":95,"module":"android.os.Handler"},{"native":false,"filename":"Handler.java","function":"handleCallback","in_app":false,"lineno":739,"module":"android.os.Handler"},{"native":false,"filename":"View.java","function":"run","in_app":false,"lineno":21147,"module":"android.view.View$PerformClick"},{"native":false,"filename":"View.java","function":"performClick","in_app":false,"lineno":5198,"module":"android.view.View"},{"native":false,"filename":"lambda","function":"onClick","in_app":true,"module":"io.sentry.sample.-$$Lambda$MainActivity$tVGPRGxxb8SivUa5SKhzp6BuXOI"},{"native":false,"filename":"MainActivity.java","function":"lambda$onCreate$2","in_app":true,"lineno":32,"module":"io.sentry.sample.MainActivity"}]},"thread_id":1,"type":"Exception","value":"java.lang.Exception: java.lang.Exception: Some exception."},{"module":"java.lang","stacktrace":{"frames":[{"native":false,"filename":"ZygoteInit.java","function":"main","in_app":false,"lineno":616,"module":"com.android.internal.os.ZygoteInit"},{"native":false,"filename":"ZygoteInit.java","function":"run","in_app":false,"lineno":726,"module":"com.android.internal.os.ZygoteInit$MethodAndArgsCaller"},{"native":true,"filename":"Method.java","function":"invoke","in_app":false,"module":"java.lang.reflect.Method"},{"native":false,"filename":"ActivityThread.java","function":"main","in_app":false,"lineno":5417,"module":"android.app.ActivityThread"},{"native":false,"filename":"Looper.java","function":"loop","in_app":false,"lineno":148,"module":"android.os.Looper"},{"native":false,"filename":"Handler.java","function":"dispatchMessage","in_app":false,"lineno":95,"module":"android.os.Handler"},{"native":false,"filename":"Handler.java","function":"handleCallback","in_app":false,"lineno":739,"module":"android.os.Handler"},{"native":false,"filename":"View.java","function":"run","in_app":false,"lineno":21147,"module":"android.view.View$PerformClick"},{"native":false,"filename":"View.java","function":"performClick","in_app":false,"lineno":5198,"module":"android.view.View"},{"native":false,"filename":"lambda","function":"onClick"," ``` Closes getsentry#298, getsentry#296. Thanks to marandaneto for the initial implementation.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
just a sample