SourceHorizon / logger

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

Web safe export #59

Closed busslina closed 6 months ago

busslina commented 7 months ago

https://github.com/SourceHorizon/logger/issues/58

Bungeefan commented 7 months ago

Hi, thanks for the PR, I am currently still contemplating whether we should solve it this way, or if there are other ways without having to provide two different library exports. I would like to keep it as simple as possible for library users.

Anyway, regarding your changes, I see no reason why you changed the imports of the tests and I also wouldn't like to call it logger_web_safe. logger_web seems to conform better to the common naming scheme of such export files in packages.

busslina commented 7 months ago

Hi, thanks for the PR, I am currently still contemplating whether we should solve it this way, or if there are other ways without having to provide two different library exports. I would like to keep it as simple as possible for library users.

Anyway, regarding your changes, I see no reason why you changed the imports of the tests and I also wouldn't like to call it logger_web_safe. logger_web seems to conform better to the common naming scheme of such export files in packages.

Both of your question have the same answer: I had this very same problem with my own libs and I adopted the same strategy. To create a 'web_safe_lib.dart' file and to use this export file instead the main one when it's possible.

But it can be done in a better way for sure ;)

As side note, I'm using this PR in my logger fork successfully.

Thanks

Bungeefan commented 6 months ago

Actually, I found a "better" way to fix the import problem without needing to provide a second library. We can just use String path instead of File file in the constructor parameter, similar to various other libraries (e.g. dio, cross_file, ...). This would remove the dart:io import from the stub, which in turn fixes the complaint from the Dart web compiler.

However, as this would be a breaking change, I will probably add the web-safe library for now and change it in a future major release.