bdrazhzhov / audio-service-mpris

Flutter audio_service plugin implementing Media Player Remote Interfacing Specification
MIT License
5 stars 4 forks source link

debugPrint prints in releasemode #2

Closed Feichtmeier closed 3 months ago

Feichtmeier commented 4 months ago

Hi :wave: Thanks for this library! Currently thinking to switch to it for linux for musicpod

I noticed that here https://github.com/bdrazhzhov/audio-service-mpris/blob/master/lib/audio_service_mpris.dart#L34 many debugPrints happen

very unintuive but those also happen in release mode https://api.flutter.dev/flutter/foundation/debugPrint.html

to avoid this you need to check for kDebugMode

bdrazhzhov commented 4 months ago

Hi Frederik!

Debug messages may be unwanted or even annoying in released applications. I found the following way to fix the issue:

void main() {
  if(kReleaseMode) {
    debugPrint = (String? message, {int? wrapWidth}) {};
  }

  runApp(const MyApp());
}

It works for the whole application and doesn't require to change all the files where debugPrint() is used.

Feichtmeier commented 4 months ago

Hi Frederik!

Debug messages may be unwanted or even annoying in released applications. I found the following way to fix the issue:

void main() {
  if(kReleaseMode) {
    debugPrint = (String? message, {int? wrapWidth}) {};
  }

  runApp(const MyApp());
}

It works for the whole application and doesn't require to change all the files where debugPrint() is used.

Thanks for your answer!

While this approach works it requires maybe too much of users of your lib. I think the default behaviour should not be to print everything to the terminal. Especially since i/o negatively impacts performance (a bit)

bdrazhzhov commented 4 months ago

I think I replace debugPrint() with log() from dart:developer.

Feichtmeier commented 4 months ago

I think I replace debugPrint() with log() from dart:developer.

sounds nice, I close my PR then and keep the fork until then because I want to use your lib :)

bdrazhzhov commented 3 months ago

Closed due to changes made in https://github.com/bdrazhzhov/audio-service-mpris/commit/e0402529d09b727776860947437333422b6476ee.