refactor: Replace debugPrint with print statements in background geofence dispatcher for logging
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
// ignore_for_file: avoid_print
|
||||||
import 'package:krow_core/core.dart';
|
import 'package:krow_core/core.dart';
|
||||||
import 'package:workmanager/workmanager.dart';
|
import 'package:workmanager/workmanager.dart';
|
||||||
|
|
||||||
@@ -15,9 +15,9 @@ import 'package:workmanager/workmanager.dart';
|
|||||||
void backgroundGeofenceDispatcher() {
|
void backgroundGeofenceDispatcher() {
|
||||||
Workmanager().executeTask(
|
Workmanager().executeTask(
|
||||||
(String task, Map<String, dynamic>? inputData) async {
|
(String task, Map<String, dynamic>? inputData) async {
|
||||||
debugPrint('[BackgroundGeofence] Task triggered: $task');
|
print('[BackgroundGeofence] Task triggered: $task');
|
||||||
debugPrint('[BackgroundGeofence] Input data: $inputData');
|
print('[BackgroundGeofence] Input data: $inputData');
|
||||||
debugPrint(
|
print(
|
||||||
'[BackgroundGeofence] Timestamp: ${DateTime.now().toIso8601String()}',
|
'[BackgroundGeofence] Timestamp: ${DateTime.now().toIso8601String()}',
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -25,13 +25,13 @@ void backgroundGeofenceDispatcher() {
|
|||||||
final double? targetLng = inputData?['targetLng'] as double?;
|
final double? targetLng = inputData?['targetLng'] as double?;
|
||||||
final String? shiftId = inputData?['shiftId'] as String?;
|
final String? shiftId = inputData?['shiftId'] as String?;
|
||||||
|
|
||||||
debugPrint(
|
print(
|
||||||
'[BackgroundGeofence] Target: lat=$targetLat, lng=$targetLng, '
|
'[BackgroundGeofence] Target: lat=$targetLat, lng=$targetLng, '
|
||||||
'shiftId=$shiftId',
|
'shiftId=$shiftId',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (targetLat == null || targetLng == null) {
|
if (targetLat == null || targetLng == null) {
|
||||||
debugPrint(
|
print(
|
||||||
'[BackgroundGeofence] Missing target coordinates, skipping check',
|
'[BackgroundGeofence] Missing target coordinates, skipping check',
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
@@ -40,7 +40,7 @@ void backgroundGeofenceDispatcher() {
|
|||||||
try {
|
try {
|
||||||
const LocationService locationService = LocationService();
|
const LocationService locationService = LocationService();
|
||||||
final location = await locationService.getCurrentLocation();
|
final location = await locationService.getCurrentLocation();
|
||||||
debugPrint(
|
print(
|
||||||
'[BackgroundGeofence] Current position: '
|
'[BackgroundGeofence] Current position: '
|
||||||
'lat=${location.latitude}, lng=${location.longitude}',
|
'lat=${location.latitude}, lng=${location.longitude}',
|
||||||
);
|
);
|
||||||
@@ -51,12 +51,12 @@ void backgroundGeofenceDispatcher() {
|
|||||||
targetLat,
|
targetLat,
|
||||||
targetLng,
|
targetLng,
|
||||||
);
|
);
|
||||||
debugPrint(
|
print(
|
||||||
'[BackgroundGeofence] Distance from target: ${distance.round()}m',
|
'[BackgroundGeofence] Distance from target: ${distance.round()}m',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (distance > BackgroundGeofenceService.geofenceRadiusMeters) {
|
if (distance > BackgroundGeofenceService.geofenceRadiusMeters) {
|
||||||
debugPrint(
|
print(
|
||||||
'[BackgroundGeofence] Worker is outside geofence '
|
'[BackgroundGeofence] Worker is outside geofence '
|
||||||
'(${distance.round()}m > '
|
'(${distance.round()}m > '
|
||||||
'${BackgroundGeofenceService.geofenceRadiusMeters.round()}m), '
|
'${BackgroundGeofenceService.geofenceRadiusMeters.round()}m), '
|
||||||
@@ -72,17 +72,17 @@ void backgroundGeofenceDispatcher() {
|
|||||||
'You appear to be more than 500m from your shift location.',
|
'You appear to be more than 500m from your shift location.',
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
debugPrint(
|
print(
|
||||||
'[BackgroundGeofence] Worker is within geofence '
|
'[BackgroundGeofence] Worker is within geofence '
|
||||||
'(${distance.round()}m <= '
|
'(${distance.round()}m <= '
|
||||||
'${BackgroundGeofenceService.geofenceRadiusMeters.round()}m)',
|
'${BackgroundGeofenceService.geofenceRadiusMeters.round()}m)',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
debugPrint('[BackgroundGeofence] Error during background check: $e');
|
print('[BackgroundGeofence] Error during background check: $e');
|
||||||
}
|
}
|
||||||
|
|
||||||
debugPrint('[BackgroundGeofence] Background check completed');
|
print('[BackgroundGeofence] Background check completed');
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user