// Copyright (C) 2023 WYATT GROUP // Please see the AUTHORS file for details. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . import 'dart:io'; import 'package:brick_generator/models/log_level.dart'; class Logger { static void log(Object? message, {LogLevel level = LogLevel.info}) { stdout.writeln('${level.prefix} ${message.toString()}'); } static void info(Object? message) { log(message); } static void error(Object? message) { log(message, level: LogLevel.error); } static void success(Object? message) { log(message, level: LogLevel.success); } static void throwError(Object error, [Object? message]) { assert( error is Exception || error is Exception, 'Only throw instances of classes extending either Exception or Error;', ); if (message != null) { Logger.error(message); } // ignore: only_throw_errors throw error; } }