code-chunks / angular2-logger

A log4j inspired logger for angular 2.
MIT License
144 stars 41 forks source link

FYI: Does not seem to work with Ionic2 in Release/Prod mode #162

Open rodneyjoyce opened 7 years ago

rodneyjoyce commented 7 years ago

This took me a while to narrow down due to the diffiulty of debugging a cordova app on a native device, but it seems that when I build an Ionic 2 app in Prod mode (AOT) then I get the white screen of death when deployed to a device. In all other modes it works great.

When I remove the Logger module then it works again - so I think something is not compatible.

This Module: 0.5.1 Ionic Framework: 2.3.0 Ionic Native: 2.9.0 Ionic App Scripts: 1.2.2 Angular Core: 2.4.8

langley-agm commented 7 years ago

Hi @rodneyjoyce

What do you mean prod mode? any of those frameworks is not been used in dev mode?

There's known issues with AoT we're working on you might want to look through other raised issues. One of them seems to be fixed if you do the manual configuration rather than using providers:

https://github.com/code-chunks/angular2-logger#custom-configuration

Could you share what errors you get in the console?

rodneyjoyce commented 7 years ago

Hi @langley-agm,

Ionic2 has a Dev build and a Prod build. The later does AOT and a whole lot of other stuff (it has it's own CLI, a bit like ng2 CLI)

It's when I use PROD build that it fails - the only error I can see is: (the problem is it is minified and deployed to a device - I haven't find a decent way of finding the exact error).

I removed my services one by one and found Logger to be causing this issue. I will check out the link above and see if it helps - thanks

main.js:2r main.js:2 EXCEPTION: No provider for t! main.js:29t.handleError main.js:29 ORIGINAL STACKTRACE: main.js:29t.handleError

Error: DI Error at new Error (native) at Error.v (file:///android_asset/www/build/polyfills.js:3:4864) at e (file:///android_asset/www/build/main.js:23:19396) at e (file:///android_asset/www/build/main.js:35:2018) at new e (file:///android_asset/www/build/main.js:35:2345) at t._throwOrNull (file:///android_asset/www/build/main.js:57:12704) at t._getByKeyDefault (file:///android_asset/www/build/main.js:57:13042) at t._getByKey (file:///android_asset/www/build/main.js:57:12423) at t.get (file:///android_asset/www/build/main.js:57:10786) at e.Object.defineProperty.get [as _LoggerService_66] (file:///android_asset/www/build/main.js:55:28660) at e.Object.defineProperty.get [as _ToastService_67] (file:///android_asset/www/build/main.js:55:28929) at e.Object.defineProperty.get [as _NetworkService_70] (file:///android_asset/www/build/main.js:55:29640) at e.getInternal (file:///android_asset/www/build/main.js:56:12037) at e.get (file:///android_asset/www/build/main.js:29:4855) at e.t.injectorGet (file:///android_asset/www/build/main.js:3:7583)

rodneyjoyce commented 7 years ago

FYI I just tried injecting custom Options and it did not help.

BTW I use this in my other Angular4 project in AOT mode and it works fine.

langley-agm commented 7 years ago

"BTW I use this in my other Angular4 project in AOT mode and it works fine."

So AOT is not the incompatible one? both projects use the same version?

"EXCEPTION: No provider for t! main.js:29t.handleError main.js:29"

The error mentions a "t" object that has a "handleError" method, I don't think we have that method in this library.

rodneyjoyce commented 7 years ago

"So AOT is not the incompatible one? " To be honest I am not entirely sure. I've just started using Ionic2 and from what I understand, the PROD flag builds it in AOT mode but probably does a whole lot of other things too. The Angular CLI is a little less of a black-box.

WRT the bottom statement - what I don't understand is why it would try to call the "handleError" method on "t".

I'm sorry, I'm not being very helpful - if anyone has any suggestions on what I can try specifically I can give that a go - the only definite thing is that by removing the Logger library (I replaced all log calls with console.log) it then builds. I'm at a bit of a dead end - hopefully some other Ionic users find this post and can add some more value?

langley-agm commented 7 years ago

t is most likely after the minification, you can see what that line is before the minification main.js:29

mzhowuwu commented 7 years ago

hi,@rodneyjoyce
I face the same issue as you described.did you fine a better way to solved this other than using console instead of.looking forward a reply.

rodneyjoyce commented 7 years ago

Unfortunately not, I had to remove this library.

m1aw commented 7 years ago

I'm having the exact same problem. As far as I could debug the problem is with the interaction with webpack. As soon as I have time I will debug it further.

Error: DI Error at v (polyfills.js:3) at e [as constructor] (main.js:18) at e [as constructor] (main.js:33) at new e (main.js:33) at t._throwOrNull (main.js:76) at t._getByKeyDefault (main.js:76) at t._getByKey (main.js:76) at t.get (main.js:76) at e.get [as _Logger_84] (main.js:48) at e.get [as ] (main.js:48) at e.get [as ] (main.js:48) at e.get [as ] (main.js:48) at e.getInternal (main.js:48) at e.get (main.js:28) at e.t.injectorGet (main.js:4)

langley-agm commented 7 years ago

Thank you @m1aw !

trebor678 commented 7 years ago

I'm having the same issue.

ERROR Error: No provider for t! at S (main.js:1) at P (main.js:1) at t._throwOrNull (main.js:3) at t._getByKeyDefault (main.js:3) at t._getByKey (main.js:3) at t.get (main.js:3) at e.get [as _Logger_83] (main.js:20) at e.getInternal (main.js:20) at e.t.get (main.js:3) at e.t (main.js:12)

langley-agm commented 7 years ago

Hi @trebor678

Those logs are from the minified code, we can't do much work with those, you'd need to turn minification off or add mappings to the actual code in order to see where the real issue is.