log static method

  1. @Deprecated('Use print')
void log(
  1. String tag,
  2. Object? object, {
  3. Level level = Level.info,
})

Print logging message if in debug or profile mode

Implementation

@Deprecated('Use print')
static void log(String tag, Object? object, {Level level = Level.info}) {
  if (!kReleaseMode) {
    String color = '\u001b[37;1m';
    switch (level) {
      case Level.info:
        color = '\x1B[34m';
        break;
      case Level.success:
        color = '\x1B[32m';
        break;
      case Level.warning:
        color = '\x1B[33m';
        break;
      case Level.error:
        color = '\x1B[31m';
        break;
      case Level.debug:
        color = '\x1B[37m';
        break;
    }

    final headerLength = tag.length + 20;
    String line = '';
    for (var i = 0; i < headerLength; i++) {
      line += '=';
    }

    developer.log('$color$line\x1B[0m');
    developer.log('$color\t\t$tag\x1B[0m');
    developer.log('$color$line\x1B[0m');
    developer.log('$color$object\x1B[0m');
    developer.log('$color \x1B[0m');
  }
}