onepub-dev / dcli

An extensive library and tooling for building console/cli applications and scripts using the Dart programming language.
236 stars 26 forks source link

Change Settings().verbose to use a callback mechanism. #141

Closed bsutton closed 2 years ago

bsutton commented 3 years ago

We currently use Settings().verbose to log calls to each dcli function. This is meant to provide a similar service to bash's set -x flag.

One problem with this method is that it builds a string on every call to verbose even if logging is suppressed.

If we change the call to use a callback mechanism then I think the string building would only occur when logging is enabled.

So the following:

Settings().verbose('Log me quickly $pwd');

becomes:

Settings().verbose(() => 'Log me quickly $pwd');

This should be done in conjunction with a review of how we log. We really need to look at selecting a logging framework which we use and recommend. It would be nice if there was something similar to java slf4j-api.logger which is able to work with an array of logging provider. This allows the user to choose their logger and dcli would then log via that provider. This may not be possible without using mirrors which I would prefer to avoid.

bsutton commented 2 years ago

The changes to verbose have been completed. I will open a new issue regarding selection of a logger.

bsutton commented 2 years ago

closing as complete and we have raised a separate issue for the logger.