flutter_platform_widgets icon indicating copy to clipboard operation
flutter_platform_widgets copied to clipboard

approach on logging

Open fredgrott opened this issue 4 years ago • 1 comments

Do we have an approach to logging?

I just started auditing the plugins I use to see which ones log and which ones do not and found flutter platform widgets do not.

In fact, we have embedded print which is not very cool:

https://github.com/stryder-dev/flutter_platform_widgets/blob/master/lib/src/widget_base.dart

in that code instead, it should be

 Widget build(BuildContext context) {
    if (isMaterial(context)) {
      return createMaterialWidget(context);
    } else if (isCupertino(context)) {
      return createCupertinoWidget(context);
    }

    return throw new UnsupportedError(
       log( 'This platform is not supported: $defaultTargetPlatform'));
  }

One of the approaches we could use is using the logging package to set up a named logger of 'FPW' and then do a logger.error('This platform is not supported: $defaultTargetPlatform')

fredgrott avatar Apr 16 '21 13:04 fredgrott

Not too keen on introducing a dependency, particularly since there is a solution natively from flutter. Additionally it is a matter of opinion as to when to log. Some packages I use do logging and they get in the way (noise) of my application logging that I control.

aqwert avatar Apr 17 '21 09:04 aqwert