Finish to add configuration tutorial
This commit is contained in:
parent
a3b25c3ee1
commit
4e8fd12fdc
9 changed files with 236 additions and 39 deletions
30
lib/utils/logger.dart
Normal file
30
lib/utils/logger.dart
Normal file
|
@ -0,0 +1,30 @@
|
|||
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');
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue