refactor: Replace debugPrint with print statements in background geofence dispatcher for logging

This commit is contained in:
Achintha Isuru
2026-03-14 00:45:18 -04:00
parent 8fcf1d9d98
commit 2889098f9f

View File

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