File tree 4 files changed +7
-10
lines changed
4 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,6 @@ abstract class BaseLoggingRepository {
16
16
17
17
String tempLogPath = '/logs' ;
18
18
19
- String get userId;
20
-
21
19
void startLogging () {
22
20
_secureLogStorage.init ();
23
21
LoggingFactory .configure (LoggingConfiguration (onLog: (value) => storeLogLine (value)));
@@ -26,16 +24,14 @@ abstract class BaseLoggingRepository {
26
24
void storeLogLine (String line) => _loggerLock.synchronized (() => _secureLogStorage.storeLogLine (line));
27
25
28
26
Future <void > uploadLog (DateTime date) async {
29
- final applicationDirectory = await getApplicationDocumentsDirectory ();
27
+ final applicationDirectory = await getApplicationCacheDirectory ();
30
28
final file = File ('${applicationDirectory .path }$tempLogPath ' );
31
29
if (file.existsSync ()) {
32
30
file.deleteSync ();
33
31
file.createSync ();
34
32
}
35
33
final log = await _secureLogStorage.getLogFromDate (date);
36
- for (final line in log) {
37
- file.writeAsStringSync (line);
38
- }
34
+ await file.writeAsString (log.join ('\n ' ));
39
35
await uploadFile (file, date);
40
36
file.deleteSync ();
41
37
}
Original file line number Diff line number Diff line change @@ -14,12 +14,10 @@ class LoggingRepository extends BaseLoggingRepository {
14
14
super .secureLogStorage,
15
15
);
16
16
17
- @override
18
- String get userId => 'TestUser' ;
19
-
20
17
@override
21
18
Future <void > uploadFile (File file, DateTime date) async {
22
- final ref = _firebaseStorage.ref ('logs/$userId /${date .shortDateFormat }.txt' );
19
+ const userId = 'TestUser' ;
20
+ final ref = _firebaseStorage.ref ('logs/$userId -${date .dottedShortDateFormat }.txt' );
23
21
await ref.putFile (file);
24
22
}
25
23
}
Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ extension DateTimeExtentions on DateTime {
9
9
10
10
String get shortDateFormat => _formatDateWithFormatString (formatString: 'dd/MM/yyyy' );
11
11
12
+ String get dottedShortDateFormat => _formatDateWithFormatString (formatString: 'dd.MM.yyyy' );
13
+
12
14
String get shortDateWeekdayFormat => _formatDateWithFormatString (formatString: 'EEEE dd/MM/yyyy' );
13
15
14
16
String _formatDateWithFormatString ({required String formatString}) {
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ class LogDetailViewModel with ChangeNotifierEx {
33
33
_isLoading = true ;
34
34
notifyListeners ();
35
35
await _loggingRepository.uploadLog (_date);
36
+ _isLoading = false ;
36
37
if (disposed) return ;
37
38
notifyListeners ();
38
39
}
You can’t perform that action at this time.
0 commit comments