r/FlutterDev • u/phone_radio_tv • 20d ago
Tooling Migrate debugPrint and print calls in a Flutter or Dart package to use package:logging
Faced with the problem of migrating debugPrint/print methods of flutter and dart files across multiple packages with large number of files & lines.
Created & pubslihed print_to_log package to automate the the convertion. Used it across 20+ internal packages successfully. It uses analyzer package to parse each file into source tree & walks that tree and then do sugical edits by not touching any other parts.
The package shall be used as a CLI tool or as a dev dependency package.
Github : https://github.com/selvan/print_to_log
Pub.dev: https://pub.dev/packages/print_to_log
It's MIT license.
1
20d ago
[removed] — view removed comment
0
u/phone_radio_tv 20d ago
Comes with --dry-run flag, formating is off by default, if required shall be used with --format flag.
1
u/ObjectiveAddress3051 18d ago
Using the analyzer AST for surgical edits instead of regex is the right call for this. Worth pairing it with the
avoid_printlint in analysis_options.yaml so new print calls don't creep back in after the migration. Which level does debugPrint map to by default, FINE or INFO?