Frezyx / talker

☎️ Advanced error handler and logger for dart and flutter apps
https://pub.dev/packages/talker
MIT License
486 stars 57 forks source link

Max length for log messages #190

Open amrgetment opened 7 months ago

amrgetment commented 7 months ago

Is your feature request related to a problem? Please describe. I have a bloc state and event that prints thousands of objects which slows down my app and it prints a very long log

Describe the solution you'd like I want a way to set the max length for each log message

Additional context I parse a CSV file with 1000 rows which makes this issue, with max length I will have cleaner logs

Frezyx commented 7 months ago

Hello @amrgetment ! Great idea, I will think how we can implement that functionality in future versions

amrgetment commented 7 months ago

@Frezyx Thanks a lot

here for bloc messages you use settings.printStateFullData, so same you could use settings.maxLength

  String _createMessage() {
    final sb = StringBuffer();
    sb.write(displayTitleWithTime);
    sb.write('\n$message');
    sb.write(
        '\n${'CURRENT state: ${settings.printStateFullData ? '\n${transition.currentState}' : transition.currentState.runtimeType}'}');
    sb.write(
        '\n${'NEXT state: ${settings.printStateFullData ? '\n${transition.nextState}' : transition.nextState.runtimeType}'}');
    return sb.toString();
  }
}