Skip to content

Commit 448b684

Browse files
committed
chore: replace print with proper logging framework
1 parent e8e9727 commit 448b684

File tree

11 files changed

+50
-41
lines changed

11 files changed

+50
-41
lines changed

lib/features/auth/presentation/bloc/auth_bloc.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,35 +81,35 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
8181
try {
8282
event.context?.read<TranscriptBloc>().add(const ClearTranscriptCache());
8383
} catch (e) {
84-
print('Note: Could not clear transcript cache. ${e.toString()}');
84+
debugPrint('Note: Could not clear transcript cache. ${e.toString()}');
8585
}
8686
try {
8787
event.context?.read<TimelineBloc>().add(ClearTimelineCache());
8888
} catch (e) {
89-
print('Note: Could not clear timeline cache. ${e.toString()}');
89+
debugPrint('Note: Could not clear timeline cache. ${e.toString()}');
9090
}
9191

9292
try {
9393
event.context?.read<EnrollmentBloc>().add(ClearEnrollmentsCache());
9494
} catch (e) {
95-
print('Note: Could not clear enrollment cache. ${e.toString()}');
95+
debugPrint('Note: Could not clear enrollment cache. ${e.toString()}');
9696
}
9797

9898
try {
9999
event.context?.read<StudentGroupsBloc>().add(ClearGroupsCache());
100100
} catch (e) {
101-
print('Note: Could not clear groups cache. ${e.toString()}');
101+
debugPrint('Note: Could not clear groups cache. ${e.toString()}');
102102
}
103103

104104
try {
105105
event.context?.read<SubjectBloc>().add(ClearSubjectCache());
106106
} catch (e) {
107-
print('Note: Could not clear subject cache. ${e.toString()}');
107+
debugPrint('Note: Could not clear subject cache. ${e.toString()}');
108108
}
109109
try {
110110
event.context?.read<ProfileBloc>().add(ClearProfileCacheEvent());
111111
} catch (e) {
112-
print('Note: Could not clear profile cache. ${e.toString()}');
112+
debugPrint('Note: Could not clear profile cache. ${e.toString()}');
113113
}
114114

115115
emit(AuthLoggedOut());

lib/features/enrollment/data/services/enrollment_cache_service.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:convert';
2+
import 'package:flutter/foundation.dart';
23
import 'package:shared_preferences/shared_preferences.dart';
34
import 'package:progres/features/enrollment/data/models/enrollment.dart';
45

@@ -19,7 +20,7 @@ class EnrollmentCacheService {
1920
);
2021
return true;
2122
} catch (e) {
22-
print('Error caching enrollments: $e');
23+
debugPrint('Error caching enrollments: $e');
2324
return false;
2425
}
2526
}
@@ -35,7 +36,7 @@ class EnrollmentCacheService {
3536
final List<dynamic> decodedJson = jsonDecode(enrollmentsString);
3637
return decodedJson.map((json) => Enrollment.fromJson(json)).toList();
3738
} catch (e) {
38-
print('Error retrieving cached enrollments: $e');
39+
debugPrint('Error retrieving cached enrollments: $e');
3940
return null;
4041
}
4142
}
@@ -51,7 +52,7 @@ class EnrollmentCacheService {
5152

5253
return DateTime.parse(timestamp);
5354
} catch (e) {
54-
print('Error getting last updated time: $e');
55+
debugPrint('Error getting last updated time: $e');
5556
return null;
5657
}
5758
}
@@ -64,7 +65,7 @@ class EnrollmentCacheService {
6465
await prefs.remove('${_lastUpdatedKeyPrefix}enrollments');
6566
return true;
6667
} catch (e) {
67-
print('Error clearing enrollment cache: $e');
68+
debugPrint('Error clearing enrollment cache: $e');
6869
return false;
6970
}
7071
}

lib/features/enrollment/presentation/bloc/enrollment_bloc.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:flutter/foundation.dart';
12
import 'package:flutter_bloc/flutter_bloc.dart';
23
import 'package:progres/features/enrollment/data/repositories/enrollment_repository_impl.dart';
34
import 'package:progres/features/enrollment/data/services/enrollment_cache_service.dart';
@@ -41,7 +42,7 @@ class EnrollmentBloc extends Bloc<EnrollmentEvent, EnrollmentState> {
4142

4243
emit(EnrollmentsLoaded(enrollments: enrollments, fromCache: false));
4344
} catch (e) {
44-
print('Error loading enrollments: $e');
45+
debugPrint('Error loading enrollments: $e');
4546

4647
final cachedEnrollments = await cacheService.getCachedEnrollments();
4748
if (cachedEnrollments != null && cachedEnrollments.isNotEmpty) {

lib/features/groups/data/services/groups_cache_service.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:convert';
2+
import 'package:flutter/foundation.dart';
23
import 'package:shared_preferences/shared_preferences.dart';
34
import 'package:progres/features/groups/data/models/group.dart';
45

@@ -19,7 +20,7 @@ class GroupsCacheService {
1920
);
2021
return true;
2122
} catch (e) {
22-
print('Error caching groups: $e');
23+
debugPrint('Error caching groups: $e');
2324
return false;
2425
}
2526
}
@@ -35,7 +36,7 @@ class GroupsCacheService {
3536
final List<dynamic> decodedJson = jsonDecode(groupsString);
3637
return decodedJson.map((json) => StudentGroup.fromJson(json)).toList();
3738
} catch (e) {
38-
print('Error retrieving cached groups: $e');
39+
debugPrint('Error retrieving cached groups: $e');
3940
return null;
4041
}
4142
}
@@ -51,7 +52,7 @@ class GroupsCacheService {
5152

5253
return DateTime.parse(timestamp);
5354
} catch (e) {
54-
print('Error getting last updated time: $e');
55+
debugPrint('Error getting last updated time: $e');
5556
return null;
5657
}
5758
}
@@ -64,7 +65,7 @@ class GroupsCacheService {
6465
await prefs.remove('${_lastUpdatedKeyPrefix}groups');
6566
return true;
6667
} catch (e) {
67-
print('Error clearing groups cache: $e');
68+
debugPrint('Error clearing groups cache: $e');
6869
return false;
6970
}
7071
}

lib/features/profile/data/services/profile_cache_service.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:convert';
2+
import 'package:flutter/foundation.dart';
23
import 'package:shared_preferences/shared_preferences.dart';
34

45
class ProfileCacheService {
@@ -14,7 +15,7 @@ class ProfileCacheService {
1415
await prefs.setString(_lastUpdatedKey, DateTime.now().toIso8601String());
1516
return true;
1617
} catch (e) {
17-
print('Error caching profile data: $e');
18+
debugPrint('Error caching profile data: $e');
1819
return false;
1920
}
2021
}
@@ -29,7 +30,7 @@ class ProfileCacheService {
2930

3031
return jsonDecode(profileDataString) as Map<String, dynamic>;
3132
} catch (e) {
32-
print('Error retrieving cached profile data: $e');
33+
debugPrint('Error retrieving cached profile data: $e');
3334
return null;
3435
}
3536
}
@@ -43,7 +44,7 @@ class ProfileCacheService {
4344

4445
return DateTime.parse(timestamp);
4546
} catch (e) {
46-
print('Error getting last updated time: $e');
47+
debugPrint('Error getting last updated time: $e');
4748
return null;
4849
}
4950
}
@@ -56,7 +57,7 @@ class ProfileCacheService {
5657
await prefs.remove(_lastUpdatedKey);
5758
return true;
5859
} catch (e) {
59-
print('Error clearing profile cache: $e');
60+
debugPrint('Error clearing profile cache: $e');
6061
return false;
6162
}
6263
}

lib/features/subject/data/services/subject_cache_service.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:convert';
2+
import 'package:flutter/foundation.dart';
23
import 'package:shared_preferences/shared_preferences.dart';
34
import 'package:progres/features/subject/data/models/course_coefficient.dart';
45

@@ -35,7 +36,7 @@ class SubjectCacheService {
3536
await prefs.setString(lastUpdatedKey, DateTime.now().toIso8601String());
3637
return true;
3738
} catch (e) {
38-
print('Error caching subject coefficients: $e');
39+
debugPrint('Error caching subject coefficients: $e');
3940
return false;
4041
}
4142
}
@@ -57,7 +58,7 @@ class SubjectCacheService {
5758
.map((json) => CourseCoefficient.fromJson(json))
5859
.toList();
5960
} catch (e) {
60-
print('Error retrieving cached subject coefficients: $e');
61+
debugPrint('Error retrieving cached subject coefficients: $e');
6162
return null;
6263
}
6364
}
@@ -76,7 +77,7 @@ class SubjectCacheService {
7677

7778
return DateTime.parse(timestamp);
7879
} catch (e) {
79-
print('Error getting last updated time: $e');
80+
debugPrint('Error getting last updated time: $e');
8081
return null;
8182
}
8283
}
@@ -98,7 +99,7 @@ class SubjectCacheService {
9899
await prefs.remove(lastUpdatedKey);
99100
return true;
100101
} catch (e) {
101-
print('Error clearing specific subject cache: $e');
102+
debugPrint('Error clearing specific subject cache: $e');
102103
return false;
103104
}
104105
}
@@ -117,7 +118,7 @@ class SubjectCacheService {
117118
}
118119
return true;
119120
} catch (e) {
120-
print('Error clearing all subject caches: $e');
121+
debugPrint('Error clearing all subject caches: $e');
121122
return false;
122123
}
123124
}

lib/features/subject/presentation/bloc/subject_bloc.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:flutter/foundation.dart';
12
import 'package:flutter_bloc/flutter_bloc.dart';
23
import 'package:equatable/equatable.dart';
34
import 'package:progres/features/subject/data/repositories/subject_repository_impl.dart';
@@ -121,7 +122,7 @@ class SubjectBloc extends Bloc<SubjectEvent, SubjectState> {
121122
await cacheService.clearAllCache();
122123
}
123124
} catch (e) {
124-
print('Error clearing subject cache: $e');
125+
debugPrint('Error clearing subject cache: $e');
125126
}
126127
}
127128
}

lib/features/timeline/data/models/course_session.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class CourseSession {
113113
// Print debug info for Sunday specifically
114114
if (jourId == 2) {
115115
// Sunday
116-
print(
116+
debugPrint(
117117
'SUNDAY EVENT: jourId $jourId ($jourLibelleFr) mapped to ${_formatDate(result)} (weekday: ${result.weekday})',
118118
);
119119
}

lib/features/timeline/data/services/timeline_cache_service.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:convert';
2+
import 'package:flutter/foundation.dart';
23
import 'package:shared_preferences/shared_preferences.dart';
34

45
class TimelineCacheService {
@@ -23,7 +24,7 @@ class TimelineCacheService {
2324
);
2425
return true;
2526
} catch (e) {
26-
print('Error caching timeline events: $e');
27+
debugPrint('Error caching timeline events: $e');
2728
return false;
2829
}
2930
}
@@ -42,7 +43,7 @@ class TimelineCacheService {
4243

4344
return jsonDecode(eventsString) as List<dynamic>;
4445
} catch (e) {
45-
print('Error retrieving cached timeline events: $e');
46+
debugPrint('Error retrieving cached timeline events: $e');
4647
return null;
4748
}
4849
}
@@ -58,7 +59,7 @@ class TimelineCacheService {
5859

5960
return DateTime.parse(timestamp);
6061
} catch (e) {
61-
print('Error getting last updated time: $e');
62+
debugPrint('Error getting last updated time: $e');
6263
return null;
6364
}
6465
}
@@ -77,7 +78,7 @@ class TimelineCacheService {
7778
}
7879
return true;
7980
} catch (e) {
80-
print('Error clearing timeline cache: $e');
81+
debugPrint('Error clearing timeline cache: $e');
8182
return false;
8283
}
8384
}

lib/features/transcript/data/services/transcript_cache_service.dart

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'dart:convert';
2+
import 'package:flutter/foundation.dart';
23
import 'package:shared_preferences/shared_preferences.dart';
34
import 'package:progres/features/transcript/data/models/academic_transcript.dart';
45
import 'package:progres/features/transcript/data/models/annual_transcript_summary.dart';
@@ -27,7 +28,7 @@ class TranscriptCacheService {
2728
);
2829
return true;
2930
} catch (e) {
30-
print('Error caching transcripts: $e');
31+
debugPrint('Error caching transcripts: $e');
3132
return false;
3233
}
3334
}
@@ -49,7 +50,7 @@ class TranscriptCacheService {
4950
.map((json) => AcademicTranscript.fromJson(json))
5051
.toList();
5152
} catch (e) {
52-
print('Error retrieving cached transcripts: $e');
53+
debugPrint('Error retrieving cached transcripts: $e');
5354
return null;
5455
}
5556
}
@@ -71,7 +72,7 @@ class TranscriptCacheService {
7172
);
7273
return true;
7374
} catch (e) {
74-
print('Error caching annual summary: $e');
75+
debugPrint('Error caching annual summary: $e');
7576
return false;
7677
}
7778
}
@@ -91,7 +92,7 @@ class TranscriptCacheService {
9192
final decodedJson = jsonDecode(summaryString);
9293
return AnnualTranscriptSummary.fromJson(decodedJson);
9394
} catch (e) {
94-
print('Error retrieving cached annual summary: $e');
95+
debugPrint('Error retrieving cached annual summary: $e');
9596
return null;
9697
}
9798
}
@@ -107,7 +108,7 @@ class TranscriptCacheService {
107108

108109
return DateTime.parse(timestamp);
109110
} catch (e) {
110-
print('Error getting last updated time: $e');
111+
debugPrint('Error getting last updated time: $e');
111112
return null;
112113
}
113114
}
@@ -128,7 +129,7 @@ class TranscriptCacheService {
128129
}
129130
return true;
130131
} catch (e) {
131-
print('Error clearing cache: $e');
132+
debugPrint('Error clearing cache: $e');
132133
return false;
133134
}
134135
}

0 commit comments

Comments
 (0)