From e597498be4a1b12646edfbb6f5d4df66b7af8b93 Mon Sep 17 00:00:00 2001 From: Ratakondala Arun Date: Fri, 8 Jul 2022 19:28:13 +0530 Subject: [PATCH] feat(logger): added logger --- lib/logger.dart | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 lib/logger.dart diff --git a/lib/logger.dart b/lib/logger.dart new file mode 100644 index 0000000000..61ae2956fb --- /dev/null +++ b/lib/logger.dart @@ -0,0 +1,33 @@ +import 'package:cli_util/cli_logging.dart'; + +export 'package:cli_util/cli_logging.dart' show Progress; + +/// Flutter Launcher Icons Logger +class FLILogger { + late Logger _logger; + + /// Returns true if this is a verbose logger + final bool isVerbose; + + /// Gives access to internal logger + Logger get rawLogger => _logger; + + /// Creates a instance of [FLILogger]. + /// In case [isVerbose] is `true`, + /// it logs all the [verbose] logs to console + FLILogger(this.isVerbose) { + final ansi = Ansi(Ansi.terminalSupportsAnsi); + _logger = isVerbose ? Logger.verbose(ansi: ansi) : Logger.standard(ansi: ansi); + } + + /// Logs error messages + void error(Object? message) => _logger.stderr('⚠️' + message.toString()); + + /// prings to console if [isVerbose] is true + void verbose(Object? message) => _logger.trace(message.toString()); + + void info(Object? message) => _logger.stdout(message.toString()); + + /// Shows progress in console + Progress progress(String message) => _logger.progress(message); +}