Closed nateshmbhat closed 4 years ago
A fix might be adding a isFlutterWeb parameter to PrettyPrinter which will remove some of the flutter library and dart-sdk specific strings from the stacktrace only when run on web.
I must have messed up my notifications settings and missed this issue. My apologies. I'll look into it tomorrow first thing.
Could you help me out and provide me with a dead simple project which displays this behaviour, I have no experience with Flutter in the browser. Thank you!
+1 A fix for this stacktraces poluting my logs in flutter web would be really nice ;) Seems @nateshmbhat has made a fix for this. @haarts You can actually get this problem in any flutter web project you create I believe. You need to switch to flutter beta channel, activate web in flutter (theres a guide for that on flutter setup), so you can run any flutter app in chrome browser. Then you will get those stackmessages. I will test the fix later to see if it solves my problem.
You can refer this guide to migrate to flutter web : https://cutt.ly/migrate-to-flutter-web
I'm currently (finally) looking into this. It appears that the stacktrace has significant different formatting on devices vs web. Your PR does not work for me because the regexes do not match (I got these kind of lines: packages/logger/src/printers/pretty_printer.dart 91:37
).
I'm devising a solution.
Could you humour me and test this branch: https://github.com/leisim/logger/tree/deal-with-flutter-web-stacktraces?
The issue is that the stacktraces from both platforms are formatted differently. In the branch I created I took your ideas but I was able to avoid the additional boolean parameter to the constructor.
I can't reproduce the kind of stacktrace you have in your initial post, that worries me a bit. But together I'm sure we'll figure it out.
Thanks for your efforts Mr. haarts! I will try to check this branch out this evening and report back
I have tested it and it looks fine now! What I did for testing:
cd "PathToExampleFolder"
flutter create .
logger:
path: ../
flutter run -d chrome
In comparison I did the above steps for the current master branch with the following polluted logs in flutter web:
Looks fine too me! :slightly_smiling_face:
That is fantastic to hear! Thank you so much for the test and the step for step outline. You really went above and beyond.
I'll wrap this up then. @nateshmbhat I'll close your PR, thanks for the valuable contribution. Then I'll create a new release.
I'm still getting this issue with v1.1.0 running on Chrome
I'll often get something like this instead of a stack trace to the relevant line number
│ #0 ../dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 910:28 get current
│ #1 ../packages/logger/src/printers/pretty_printer.dart 129:53 log
├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
│ ⛔ Expected a value of type 'String', but got one of type 'int'
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────```
I'm still getting this issue with v1.1.0 running on Chrome
I'll often get something like this instead of a stack trace to the relevant line number
│ #0 ../dart-sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart 910:28 get current │ #1 ../packages/logger/src/printers/pretty_printer.dart 129:53 log ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄ │ ⛔ Expected a value of type 'String', but got one of type 'int' └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────```
Do you know that can I remove lines I write below and also add file name at the beginning of │ ⛔ Expected a value of type 'String', but got one of type 'int ?
│ #1 ../packages/logger/src/printers/pretty_printer.dart 129:53 log
Right now , on flutter web , it gives error saying :
For every log its giving these errors. Please let us know of any workaround for this ....