1// Copyright 2016 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5import 'artifacts.dart'; 6import 'base/config.dart'; 7import 'base/context.dart'; 8import 'base/logger.dart'; 9import 'base/terminal.dart'; 10import 'cache.dart'; 11 12Logger get logger => context.get<Logger>(); 13Cache get cache => Cache.instance; 14Config get config => Config.instance; 15Artifacts get artifacts => Artifacts.instance; 16 17/// Display an error level message to the user. Commands should use this if they 18/// fail in some way. 19/// 20/// Set [emphasis] to true to make the output bold if it's supported. 21/// Set [color] to a [TerminalColor] to color the output, if the logger 22/// supports it. The [color] defaults to [TerminalColor.red]. 23void printError( 24 String message, { 25 StackTrace stackTrace, 26 bool emphasis, 27 TerminalColor color, 28 int indent, 29 int hangingIndent, 30 bool wrap, 31}) { 32 logger.printError( 33 message, 34 stackTrace: stackTrace, 35 emphasis: emphasis ?? false, 36 color: color, 37 indent: indent, 38 hangingIndent: hangingIndent, 39 wrap: wrap, 40 ); 41} 42 43/// Display normal output of the command. This should be used for things like 44/// progress messages, success messages, or just normal command output. 45/// 46/// Set `emphasis` to true to make the output bold if it's supported. 47/// 48/// Set `newline` to false to skip the trailing linefeed. 49/// 50/// If `indent` is provided, each line of the message will be prepended by the 51/// specified number of whitespaces. 52void printStatus( 53 String message, { 54 bool emphasis, 55 bool newline, 56 TerminalColor color, 57 int indent, 58 int hangingIndent, 59 bool wrap, 60}) { 61 logger.printStatus( 62 message, 63 emphasis: emphasis ?? false, 64 color: color, 65 newline: newline ?? true, 66 indent: indent, 67 hangingIndent: hangingIndent, 68 wrap: wrap, 69 ); 70} 71 72/// Use this for verbose tracing output. Users can turn this output on in order 73/// to help diagnose issues with the toolchain or with their setup. 74void printTrace(String message) => logger.printTrace(message); 75