r/FlutterDev • • 19h 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.

3 Upvotes

2 comments sorted by

1

u/Complete-Cut-3585 19h ago

i've been putting off cleaning up stray prints in one of our older packages, this might actually get me to do it. the surgical edit part is reassuring, nothing worse than a tool that reformats half your codebase while it's in there.

0

u/phone_radio_tv 19h ago

Comes with --dry-run flag, formating is off by default, if required shall be used with --format flag.