1
0
Fork 0
mrtiboute/lib/utils/logger.dart

30 lines
737 B
Dart

import 'package:flutter/foundation.dart';
enum LoggerType { info, warning, error }
class Logger {
static void log(LoggerType logType, Object? instance, String message) {
if (kDebugMode) {
String className;
if (instance is Type) {
className = instance.toString();
} else {
className = instance?.runtimeType.toString() ?? 'GLOBAL';
}
String cat;
switch (logType) {
case LoggerType.info:
cat = 'INFO';
break;
case LoggerType.warning:
cat = 'WARNING';
break;
case LoggerType.error:
cat = 'ERROR';
break;
}
// ignore: avoid_print
print('[$cat][$className] $message');
}
}
}