initLogger method

void initLogger({
  1. bool jsonOutput = false,
  2. bool useColors = true,
})

Initialize the command with a logger instance.

Must be called before using any logger methods.

Parameters:

  • jsonOutput: If true, configures logger for JSON output
  • useColors: If true, enables colored terminal output

Example:

final command = MyCommand();
command.initLogger(jsonOutput: false, useColors: true);
await command.execute();

Implementation

void initLogger({bool jsonOutput = false, bool useColors = true}) {
  _jsonOutput = jsonOutput;
  _useColors = useColors;
  _logger = Logger(
    level: jsonOutput ? Level.error : Level.info,
  );
}