globals.dart 1.63 KB
Newer Older
1 2 3 4
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5
import 'artifacts.dart';
6
import 'base/config.dart';
7 8
import 'base/context.dart';
import 'base/logger.dart';
9
import 'cache.dart';
10 11

Logger get logger => context[Logger];
12
Cache get cache => Cache.instance;
13
Config get config => Config.instance;
14
Artifacts get artifacts => Artifacts.instance;
15

16 17 18 19 20 21
/// Display an error level message to the user. Commands should use this if they
/// fail in some way.
void printError(String message, [StackTrace stackTrace]) => logger.printError(message, stackTrace);

/// Display normal output of the command. This should be used for things like
/// progress messages, success messages, or just normal command output.
22 23 24 25 26 27 28
///
/// Set `emphasis` to true to make the output bold if it's supported.
///
/// Set `newline` to false to skip the trailing linefeed.
///
/// If `ansiAlternative` is provided, and the terminal supports color, that
/// string will be printed instead of the message.
29 30 31 32 33 34 35 36 37 38 39 40 41
///
/// If `indent` is provided, each line of the message will be prepended by the specified number of
/// whitespaces.
void printStatus(
  String message,
  { bool emphasis: false, bool newline: true, String ansiAlternative, int indent }) {
  logger.printStatus(
    message,
    emphasis: emphasis,
    newline: newline,
    ansiAlternative: ansiAlternative,
    indent: indent
  );
42
}
43 44 45 46

/// Use this for verbose tracing output. Users can turn this output on in order
/// to help diagnose issues with the toolchain or with their setup.
void printTrace(String message) => logger.printTrace(message);