child method

MelosLogger child(
  1. String message, {
  2. String prefix = '└> ',
  3. bool stderr = false,
  4. String? group,
})

Implementation

MelosLogger child(
  String message, {
  String prefix = '└> ',
  bool stderr = false,
  String? group,
}) {
  final childIndentation = ' ' * AnsiStyles.strip(prefix).length;
  final logger = MelosLogger(
    _logger,
    indentation: '$_indentation$_childIndentation',
    childIndentation: childIndentation,
  );

  final lines = message.split('\n');
  var isFirstLine = true;
  for (final line in lines) {
    final prefixedLine = '${isFirstLine ? prefix : childIndentation}$line';
    if (stderr) {
      logger.error(prefixedLine, group: group, label: false);
    } else {
      logger.log(prefixedLine, group: group);
    }
    isFirstLine = false;
  }

  return logger;
}