Update
Logging data Try-catch function
This commit is contained in:
39
lib/product/utils/app_logger_utils.dart
Normal file
39
lib/product/utils/app_logger_utils.dart
Normal file
@@ -0,0 +1,39 @@
|
||||
import 'package:logger/logger.dart';
|
||||
|
||||
class AppLoggerUtils{
|
||||
static final Logger _logger = Logger(
|
||||
printer: PrettyPrinter(
|
||||
methodCount: 2,
|
||||
errorMethodCount: 8,
|
||||
lineLength: 120,
|
||||
colors: true,
|
||||
printEmojis: true,
|
||||
dateTimeFormat: (DateTime dateTime) {
|
||||
// Tùy chỉnh định dạng thời gian
|
||||
return '[${DateTime.now().toLocal().toString().split(' ')[1]}]';
|
||||
},
|
||||
// dateTimeFormat: DateTimeFormat.dateAndTime
|
||||
),
|
||||
level: Level.debug, // Cấp độ log tối thiểu (có thể thay đổi trong môi trường production)
|
||||
);
|
||||
|
||||
static void debug(String message, [dynamic error, StackTrace? stackTrace]) {
|
||||
_logger.d(message);
|
||||
}
|
||||
|
||||
static void info(String message, [dynamic error, StackTrace? stackTrace]) {
|
||||
_logger.i(message);
|
||||
}
|
||||
|
||||
static void warning(String message, [dynamic error, StackTrace? stackTrace]) {
|
||||
_logger.w(message, error: error, stackTrace: stackTrace);
|
||||
}
|
||||
|
||||
static void error(String message, [dynamic error, StackTrace? stackTrace]) {
|
||||
_logger.e(message, error: error, stackTrace: stackTrace);
|
||||
}
|
||||
|
||||
static void trace(String message, [dynamic error, StackTrace? stackTrace]) {
|
||||
_logger.t(message, error: error, stackTrace: stackTrace);
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class DeviceUtils {
|
||||
String provinceID = parts[0];
|
||||
String districtID = parts[1];
|
||||
String wardID = parts[2];
|
||||
|
||||
|
||||
Province province = await apiServices.getProvinceByID(provinceID);
|
||||
District district = await apiServices.getDistrictByID(districtID);
|
||||
Ward ward = await apiServices.getWardByID(wardID);
|
||||
|
||||
Reference in New Issue
Block a user