simc / logger

Small, easy to use and extensible logger which prints beautiful logs.
https://pub.dev/packages/logger
MIT License
1.07k stars 129 forks source link

when flutter is run on browser , it has lot of extra stack trace strings which get printed everytime. #40

Closed nateshmbhat closed 4 years ago

nateshmbhat commented 4 years ago

Right now , on flutter web , it gives error saying :

│ package:dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 248:20  get current
js_primitives.dart:32 │ package:logger/src/printers/pretty_printer.dart 89:53                                 log
js_primitives.dart:32 │ package:logger/src/logger.dart 124:29                                                 log
js_primitives.dart:32 │ package:logger/src/logger.dart 85:5                                                   d
js_primitives.dart:32 │ package:core/common_modules/logger.dart 26:63                                         d
js_primitives.dart:32 │ package:dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 47:50            onValue
js_primitives.dart:32 │ package:dart-sdk/lib/async/zone.dart 1381:54                                          runUnary
js_primitives.dart:32 │ package:dart-sdk/lib/async/future_impl.dart 140:18                                    handleValue
js_primitives.dart:32 │ package:dart-sdk/lib/async/future_impl.dart 682:44                                    handleValueCallback
js_primitives.dart:32 │ package:dart-sdk/lib/async/future_impl.dart 711:32                                    _propagateToListeners
js_primitives.dart:32 │ package:dart-sdk/lib/async/future_impl.dart 526:5                                     [_completeWithValue]
js_primitives.dart:32 │ package:dart-sdk/lib/async/future_impl.dart 556:7                                     callback
js_primitives.dart:32 │ package:dart-sdk/lib/async/schedule_microtask.dart 43:11                              _microtaskLoop
js_primitives.dart:32 │ package:dart-sdk/lib/async/schedule_microtask.dart 52:5                               _startMicrotaskLoop
js_primitives.dart:32 │ package:dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 168:15           <fn>

For every log its giving these errors. Please let us know of any workaround for this ....

nateshmbhat commented 4 years ago

Please refer these issues :

https://github.com/flutter/flutter/issues/37635 https://github.com/creativecreatorormaybenot/flutter/commit/fc566078a37b336dd2ba068880ef06fe6db4a8fe

nateshmbhat commented 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.

haarts commented 4 years ago

I must have messed up my notifications settings and missed this issue. My apologies. I'll look into it tomorrow first thing.

haarts commented 4 years ago

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!

Cocotus commented 4 years ago

+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.

nateshmbhat commented 4 years ago

You can refer this guide to migrate to flutter web : https://cutt.ly/migrate-to-flutter-web

haarts commented 4 years ago

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.

haarts commented 4 years ago

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.

Cocotus commented 4 years ago

Thanks for your efforts Mr. haarts! I will try to check this branch out this evening and report back

Cocotus commented 4 years ago

I have tested it and it looks fine now! What I did for testing:

In comparison I did the above steps for the current master branch with the following polluted logs in flutter web: Image of Yaktocat

Looks fine too me! :slightly_smiling_face:

haarts commented 4 years ago

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.

georgeman93 commented 2 years ago

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'
└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────```
ugurberkecan commented 1 year ago

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 ?

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