Line data Source code
1 : part of rx_bloc_generator; 2 : 3 : /// The global logJet symbol. 4 : const Symbol _logKey = #buildLog; 5 : 6 : /// The log instance for the currently running BuildStep. 7 3 : Logger? get log => Zone.current[_logKey] as Logger?; 8 : 9 : /// Logs message as a `severe` error displayed in red color for easier noticing. 10 1 : void _logError(String str) { 11 : final exceptionStr = 'Exception: '; 12 : var msg = str; 13 1 : if (msg.contains(exceptionStr)) { 14 0 : msg = msg.substring(msg.indexOf(exceptionStr) + exceptionStr.length); 15 : } 16 1 : msg = '[ERROR] $msg'; 17 1 : if (log != null) { 18 0 : log!.severe('\n${msg.toRedString()}\n'); 19 : } else { 20 3 : print('\n${msg.toRedString()}\n'); 21 : } 22 : } 23 : 24 : /// Logs a package error with the suggestion to report it 25 0 : void _reportIssue(String msg, String copyBlock) { 26 0 : _logError('$msg\n\n' 27 : 'Please, report the problem at ' 28 : 'https://github.com/Prime-Holding/rx_bloc/issues ' 29 : 'providing the information form the `COPY BLOCK` below.\n\n' 30 : '----------START COPY BLOCK----------\n\n' 31 : '$copyBlock\n\n' 32 : '----------END COPY BLOCK----------\n'); 33 : }