user93796
user93796

Reputation: 18379

Good logging approach in Flutter

What is a good logging approach in flutter.

Options

  1. print() //bad

  2. log() method

  3. https://pub.dev/packages/logger

I am looking for something as easy as it is in native android. Eg, Log.d()which works in all cases like having to be called from widget or not.

Upvotes: 1

Views: 2768

Answers (2)

Jack'
Jack'

Reputation: 2508

I recommend the third option, so that you can use different levels for your logs :

logger.v("Verbose log");
logger.d("Debug log");
logger.i("Info log");
logger.w("Warning log");
logger.e("Error log");
logger.wtf("What a terrible failure log");

Upvotes: 0

Augustin R
Augustin R

Reputation: 7799

print() is not "bad" as you say.

However with logger package you can display several types of logs like warnings, infos, debug logs... Which is visually better than print.

Upvotes: 1

Related Questions