mason_logger 0.1.0-dev.13 icon indicating copy to clipboard operation
mason_logger: ^0.1.0-dev.13 copied to clipboard

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

mason_logger #

build coverage Pub style: very good analysis License: MIT

A reusable logger used by the Mason CLI.

import 'package:mason_logger/mason_logger.dart';

Future<void> main() async {
  // Use the various APIs to log to stdout.
  final logger = Logger()
    ..info('info')
    ..alert('alert')
    ..err('error')
    ..success('success')
    ..warn('warning')
    ..detail('detail');

  // Prompt for user input.
  final favoriteAnimal = logger.prompt(
    'What is your favorite animal?',
    defaultValue: '🐈',
  );

  /// Ask user to choose an option.
  final favoriteColor = logger.chooseOne(
    'What is your favorite color?',
    choices: ['red', 'green', 'blue'],
    defaultValue: 'blue',
  );

  /// Ask user to choose zero or more options.
  final desserts = logger.chooseAny(
    'Which desserts do you like?',
    choices: ['🍦', '🍪', '🍩'],
  );

  // Ask for user confirmation.
  final likesCats = logger.confirm('Do you like cats?', defaultValue: true);

  // Show a progress message while performing an asynchronous operation.
  final progress = logger.progress('Calculating');
  await Future<void>.delayed(const Duration(seconds: 1));

  // Show a completion message when the asynchronous operation has completed.
  progress.complete('Done!');

  // Use the user provided input.
  logger
    ..info('Your favorite animal is a $favoriteAnimal!')
    ..alert(likesCats ? 'You are a cat person!' : 'You are not a cat person.');
}
8
likes
130
pub points
79%
popularity

Publisher

verified publisher iconbrickhub.dev

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

Icon for licenses.MIT (LICENSE)

Dependencies

meta, universal_io

More

Packages that depend on mason_logger