mason_logger 0.1.0-dev.14 copy "mason_logger: ^0.1.0-dev.14" to clipboard
mason_logger: ^0.1.0-dev.14 copied to clipboard

A reusable Dart logger used by the Mason CLI (package:mason_cli).

example/main.dart

import 'package:mason_logger/mason_logger.dart';

Future<void> main() async {
  final logger = Logger()
    ..info('info')
    ..alert('alert')
    ..err('error')
    ..success('success')
    ..warn('warning')
    ..detail('detail')
    ..info('');

  final favoriteColor = logger.chooseOne(
    'Pick a color.',
    choices: ['red', 'green', 'blue'],
    defaultValue: 'blue',
  );

  logger.info('Got it, $favoriteColor it is!');

  final desserts = logger.chooseAny(
    'Which desserts do you like?',
    choices: ['🍦', '🍪', '🍩'],
  );

  logger.info('Awesome, $desserts it is!');

  final favoriteAnimal = logger.prompt(
    'What is your favorite animal?',
    defaultValue: '🐈',
  );
  final likesCats = logger.confirm('Do you like cats?', defaultValue: true);
  final progress = logger.progress('Calculating');
  await Future<void>.delayed(const Duration(milliseconds: 500));
  progress.update('Halfway!');
  await Future<void>.delayed(const Duration(milliseconds: 500));
  progress.complete('Done!');
  logger
    ..info('Your favorite animal is a $favoriteAnimal!')
    ..alert(likesCats ? 'You are a cat person!' : 'You are not a cat person.');

  final failing = logger.progress('Trying to fail now!');
  await Future<void>.delayed(const Duration(seconds: 1));
  failing.fail('See I failed!');

  final canceling = logger.progress('Trying to cancel now!');
  await Future<void>.delayed(const Duration(seconds: 1));
  canceling.cancel();
  logger.info('Done!');
}
37
likes
0
pub points
98%
popularity

Publisher

verified publisherbrickhub.dev

A reusable Dart logger used by the Mason CLI (package:mason_cli).

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

meta, universal_io

More

Packages that depend on mason_logger