ColorizeLogger class

Renders progress to the terminal and a diagnostic trail to a log file.

The two outputs are deliberately different. The terminal gets a compact, symbol based view meant to be read while it scrolls:

▸ Android Build and deploy
  › Build Android
    $ flutter build aab --release --pub
    ✓ 1m 24s
      app-release.aab  42.7 MB  9f2a1c0b3d4e

The log file gets a timestamped, level prefixed line per message, which is what you actually want when grepping a failed CI run:

12:13:51.140  INFO   Build Android
12:13:51.141  DEBUG  flutter build aab --release --pub

Every message passes through redact first, so credentials registered with registerSecret never reach either destination - not even when a child process echoes them back.

Constructors

ColorizeLogger([bool isVerbose = false])
Creates a new ColorizeLogger instance.

Properties

hashCode int
The hash code for this object.
no setterinherited
isVerbose bool
Whether debug messages are shown.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

log(String message, {LogLevel level = LogLevel.info}) → void
Logs a message with the specified level.
logCommand(String command) → void
Logs the command that is about to run, as a shell-style $ line.
logDebug(String message) → void
Logs a debug message, shown only with --verbose.
logDetail(String message) → void
Logs de-emphasised information that hangs off the line above it.
logEmpty() → void
Logs an empty line to separate blocks. Never written to the log file.
logError(String message) → void
Logs a failure, prefixed with in red.
logErrorVerbose(String message) → void
Logs a failure that is only shown with --verbose.
logGroup(String message) → void
Announces a group such as a task, prefixed with in bold.
logHeading(String message) → void
Logs a bold section heading.
logInfo(String message) → void
Logs a neutral message with no prefix and no color.
logNote(String message) → void
Logs a de-emphasised aside at the current level.
logStep(String message) → void
Announces a step that is starting, prefixed with in bold cyan.
logSuccess(String message) → void
Logs a success, prefixed with in green.
logWarning(String message) → void
Logs a warning, prefixed with ! in yellow.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

fileLoggingEnabled bool
Whether messages are persisted to disk.
no setter
indentLevel int
Current indentation depth. Each level is two spaces.
getter/setter pair
logFilePath String
The path of the file every log line is appended to.
getter/setter pair
reserveStdout bool
Whether stdout is reserved for machine readable output.
getter/setter pair
useColors bool
Whether ANSI colors are emitted to the terminal.
getter/setter pair
useUnicode bool
Whether the unicode glyph set is used instead of the ASCII fallback.
getter/setter pair
verbosity LogVerbosity
How much reaches the terminal. The log file always receives everything.
getter/setter pair

Static Methods

bold(String text) String
Styles text as a heading.
clearSecrets() → void
Clears all registered secrets. Intended for tests.
dim(String text) String
Styles text as de-emphasised secondary information.
group<T>(Future<T> body()) Future<T>
Runs body with the output indented one extra level.
maskSecretArguments(List<String> arguments) String
Renders arguments with the value of every credential option masked.
redact(String message) String
Replaces every registered secret in message with ***.
registerSecret(String? value) → void
Registers a value that must be masked in every future log line.
retargetColors() → void
Re-evaluates useColors for the stream the human output will use.
startLogFile(List<String> arguments) → void
Starts a fresh log file and writes the run header.
stripAnsi(String text) String
Removes every ANSI escape sequence from text.

Constants

secretAbbreviations → const Map<String, Set<String>>
Short forms of credential options, by the sub-command that declares them.