diff --git a/integration_test/log_rotate_test.dart b/integration_test/log_rotate_test.dart new file mode 100644 index 00000000..d86347dc --- /dev/null +++ b/integration_test/log_rotate_test.dart @@ -0,0 +1,30 @@ +import 'dart:io'; +import 'dart:typed_data'; + +import 'package:app/src/config/config_log.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:path_provider/path_provider.dart'; + +main(){ + test('test log rotation by date and size', () async { + TestWidgetsFlutterBinding.ensureInitialized(); + String path = (await getApplicationDocumentsDirectory()).path; + DateTime oldDate = DateTime.now().subtract(const Duration(days:16)); + String filenameOld = "${oldDate.year.toString()}${oldDate.month.toString().padLeft(2, '0')}${ + oldDate.day.toString().padLeft(2, '0')}.log"; + File file = File('$path/$filenameOld'); + file.writeAsStringSync("test log\n", mode: FileMode.append); + String filename = "${DateTime.now().year.toString()}${DateTime.now().month.toString().padLeft(2, '0')}${ + DateTime.now().day.toString().padLeft(2, '0')}.log"; + File fileBig = File('$path/$filename'); + Uint8List bytes = Uint8List(2000000); + fileBig.writeAsBytesSync(bytes); + Directory dir = Directory(path); + List filesBefore = (await dir.list().toList()).whereType().toList(); + expect(filesBefore.length,2); + await ConfigLog().init(); + List filesAfter = (await dir.list().toList()).whereType().toList(); + expect(filesAfter.length,1); + expect(filesAfter.first.path.endsWith(".1"),true); + }); +} \ No newline at end of file diff --git a/ios/Podfile.lock b/ios/Podfile.lock new file mode 100644 index 00000000..2da87491 --- /dev/null +++ b/ios/Podfile.lock @@ -0,0 +1,268 @@ +PODS: + - Amplitude (8.5.0) + - amplitude_flutter (0.0.1): + - Amplitude (= 8.5.0) + - Flutter + - AppAuth (1.5.0): + - AppAuth/Core (= 1.5.0) + - AppAuth/ExternalUserAgent (= 1.5.0) + - AppAuth/Core (1.5.0) + - AppAuth/ExternalUserAgent (1.5.0): + - AppAuth/Core + - barcode_scan2 (0.0.1): + - Flutter + - MTBBarcodeScanner + - SwiftProtobuf + - Firebase/CoreOnly (8.15.0): + - FirebaseCore (= 8.15.0) + - Firebase/DynamicLinks (8.15.0): + - Firebase/CoreOnly + - FirebaseDynamicLinks (~> 8.15.0) + - firebase_core (1.18.0): + - Firebase/CoreOnly (= 8.15.0) + - Flutter + - firebase_dynamic_links (4.2.6): + - Firebase/DynamicLinks (= 8.15.0) + - firebase_core + - Flutter + - FirebaseCore (8.15.0): + - FirebaseCoreDiagnostics (~> 8.0) + - GoogleUtilities/Environment (~> 7.7) + - GoogleUtilities/Logger (~> 7.7) + - FirebaseCoreDiagnostics (8.15.0): + - GoogleDataTransport (~> 9.1) + - GoogleUtilities/Environment (~> 7.7) + - GoogleUtilities/Logger (~> 7.7) + - nanopb (~> 2.30908.0) + - FirebaseDynamicLinks (8.15.0): + - FirebaseCore (~> 8.0) + - Flutter (1.0.0) + - flutter_appauth (0.0.1): + - AppAuth (= 1.5.0) + - Flutter + - flutter_secure_storage (3.3.1): + - Flutter + - FMDB/SQLCipher (2.7.5): + - SQLCipher + - GoogleDataTransport (9.1.4): + - GoogleUtilities/Environment (~> 7.7) + - nanopb (< 2.30910.0, >= 2.30908.0) + - PromisesObjC (< 3.0, >= 1.2) + - GoogleUtilities/Environment (7.7.0): + - PromisesObjC (< 3.0, >= 1.2) + - GoogleUtilities/Logger (7.7.0): + - GoogleUtilities/Environment + - integration_test (0.0.1): + - Flutter + - MTBBarcodeScanner (5.0.11) + - nanopb (2.30908.0): + - nanopb/decode (= 2.30908.0) + - nanopb/encode (= 2.30908.0) + - nanopb/decode (2.30908.0) + - nanopb/encode (2.30908.0) + - package_info (0.0.1): + - Flutter + - package_info_plus (0.4.5): + - Flutter + - path_provider_ios (0.0.1): + - Flutter + - permission_handler_apple (9.0.4): + - Flutter + - PromisesObjC (2.1.1) + - Sentry (7.19.0): + - Sentry/Core (= 7.19.0) + - Sentry/Core (7.19.0) + - sentry_flutter (0.0.1): + - Flutter + - FlutterMacOS + - Sentry (~> 7.19.0) + - share_plus (0.0.1): + - Flutter + - shared_preferences_ios (0.0.1): + - Flutter + - sqflite (0.0.2): + - Flutter + - FMDB/SQLCipher (>= 2.7.5) + - SQLCipher (~> 4.4.0) + - sqflite_sqlcipher (0.0.1): + - Flutter + - FMDB/SQLCipher (~> 2.7.5) + - SQLCipher (= 4.4.2) + - SQLCipher (4.4.2): + - SQLCipher/standard (= 4.4.2) + - SQLCipher/common (4.4.2) + - SQLCipher/standard (4.4.2): + - SQLCipher/common + - SwiftProtobuf (1.19.0) + - url_launcher_ios (0.0.1): + - Flutter + - video_player_avfoundation (0.0.1): + - Flutter + - wakelock (0.0.1): + - Flutter + - webview_flutter_wkwebview (0.0.1): + - Flutter + - zendesk_flutter (0.0.1): + - Flutter + - ZendeskSupportProvidersSDK + - ZendeskSupportSDK + - ZendeskCommonUISDK (6.1.4) + - ZendeskCoreSDK (2.7.0) + - ZendeskMessagingAPISDK (3.8.5): + - ZendeskSDKConfigurationsSDK (= 1.1.11) + - ZendeskMessagingSDK (3.8.5): + - ZendeskCommonUISDK (= 6.1.4) + - ZendeskMessagingAPISDK (= 3.8.5) + - ZendeskSDKConfigurationsSDK (1.1.11) + - ZendeskSupportProvidersSDK (5.5.0): + - ZendeskCoreSDK (= 2.7.0) + - ZendeskSupportSDK (5.5.0): + - ZendeskMessagingSDK (= 3.8.5) + - ZendeskSupportProvidersSDK (= 5.5.0) + +DEPENDENCIES: + - amplitude_flutter (from `.symlinks/plugins/amplitude_flutter/ios`) + - barcode_scan2 (from `.symlinks/plugins/barcode_scan2/ios`) + - firebase_core (from `.symlinks/plugins/firebase_core/ios`) + - firebase_dynamic_links (from `.symlinks/plugins/firebase_dynamic_links/ios`) + - Flutter (from `Flutter`) + - flutter_appauth (from `.symlinks/plugins/flutter_appauth/ios`) + - flutter_secure_storage (from `.symlinks/plugins/flutter_secure_storage/ios`) + - integration_test (from `.symlinks/plugins/integration_test/ios`) + - package_info (from `.symlinks/plugins/package_info/ios`) + - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) + - path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`) + - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) + - sentry_flutter (from `.symlinks/plugins/sentry_flutter/ios`) + - share_plus (from `.symlinks/plugins/share_plus/ios`) + - shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`) + - sqflite (from `.symlinks/plugins/sqflite/ios`) + - sqflite_sqlcipher (from `.symlinks/plugins/sqflite_sqlcipher/ios`) + - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) + - video_player_avfoundation (from `.symlinks/plugins/video_player_avfoundation/ios`) + - wakelock (from `.symlinks/plugins/wakelock/ios`) + - webview_flutter_wkwebview (from `.symlinks/plugins/webview_flutter_wkwebview/ios`) + - zendesk_flutter (from `.symlinks/plugins/zendesk_flutter/ios`) + - ZendeskSupportProvidersSDK + - ZendeskSupportSDK + +SPEC REPOS: + trunk: + - Amplitude + - AppAuth + - Firebase + - FirebaseCore + - FirebaseCoreDiagnostics + - FirebaseDynamicLinks + - FMDB + - GoogleDataTransport + - GoogleUtilities + - MTBBarcodeScanner + - nanopb + - PromisesObjC + - Sentry + - SQLCipher + - SwiftProtobuf + - ZendeskCommonUISDK + - ZendeskCoreSDK + - ZendeskMessagingAPISDK + - ZendeskMessagingSDK + - ZendeskSDKConfigurationsSDK + - ZendeskSupportProvidersSDK + - ZendeskSupportSDK + +EXTERNAL SOURCES: + amplitude_flutter: + :path: ".symlinks/plugins/amplitude_flutter/ios" + barcode_scan2: + :path: ".symlinks/plugins/barcode_scan2/ios" + firebase_core: + :path: ".symlinks/plugins/firebase_core/ios" + firebase_dynamic_links: + :path: ".symlinks/plugins/firebase_dynamic_links/ios" + Flutter: + :path: Flutter + flutter_appauth: + :path: ".symlinks/plugins/flutter_appauth/ios" + flutter_secure_storage: + :path: ".symlinks/plugins/flutter_secure_storage/ios" + integration_test: + :path: ".symlinks/plugins/integration_test/ios" + package_info: + :path: ".symlinks/plugins/package_info/ios" + package_info_plus: + :path: ".symlinks/plugins/package_info_plus/ios" + path_provider_ios: + :path: ".symlinks/plugins/path_provider_ios/ios" + permission_handler_apple: + :path: ".symlinks/plugins/permission_handler_apple/ios" + sentry_flutter: + :path: ".symlinks/plugins/sentry_flutter/ios" + share_plus: + :path: ".symlinks/plugins/share_plus/ios" + shared_preferences_ios: + :path: ".symlinks/plugins/shared_preferences_ios/ios" + sqflite: + :path: ".symlinks/plugins/sqflite/ios" + sqflite_sqlcipher: + :path: ".symlinks/plugins/sqflite_sqlcipher/ios" + url_launcher_ios: + :path: ".symlinks/plugins/url_launcher_ios/ios" + video_player_avfoundation: + :path: ".symlinks/plugins/video_player_avfoundation/ios" + wakelock: + :path: ".symlinks/plugins/wakelock/ios" + webview_flutter_wkwebview: + :path: ".symlinks/plugins/webview_flutter_wkwebview/ios" + zendesk_flutter: + :path: ".symlinks/plugins/zendesk_flutter/ios" + +SPEC CHECKSUMS: + Amplitude: ef9ed339ddd33c9183edf63fa4bbaa86cf873321 + amplitude_flutter: 8ddb231989e68ed8c005c838d7fc59edbca09833 + AppAuth: 80317d99ac7ff2801a2f18ff86b48cd315ed465d + barcode_scan2: 0af2bb63c81b4565aab6cd78278e4c0fa136dbb0 + Firebase: 5f8193dff4b5b7c5d5ef72ae54bb76c08e2b841d + firebase_core: b14c1cfa29b9eb316345f74d1489328283825d6d + firebase_dynamic_links: 007ad1d6eb991a53b4baacf215adb4de62df11e2 + FirebaseCore: 5743c5785c074a794d35f2fff7ecc254a91e08b1 + FirebaseCoreDiagnostics: 92e07a649aeb66352b319d43bdd2ee3942af84cb + FirebaseDynamicLinks: 1dc816ef789c5adac6fede0b46d11478175c70e4 + Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a + flutter_appauth: 2c4a407e6d649df3f2308375fb891822dcff291b + flutter_secure_storage: 7953c38a04c3fdbb00571bcd87d8e3b5ceb9daec + FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a + GoogleDataTransport: 5fffe35792f8b96ec8d6775f5eccd83c998d5a3b + GoogleUtilities: e0913149f6b0625b553d70dae12b49fc62914fd1 + integration_test: a1e7d09bd98eca2fc37aefd79d4f41ad37bdbbe5 + MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb + nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96 + package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 + package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e + path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02 + permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce + PromisesObjC: ab77feca74fa2823e7af4249b8326368e61014cb + Sentry: d6b16e66a0ad0c39a0b76d9a1194e68e78c37ce6 + sentry_flutter: 609b096af497fa64af7c6c94e792d0780aa472a6 + share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68 + shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad + sqflite: c0667567fd3e682beb9509976c08bc2325429aab + sqflite_sqlcipher: 70eb7fd8d4f0b0352d0bde5cf345b810737f54bb + SQLCipher: 1ab0b9486a77d141e72e92ff30681926ed79c07a + SwiftProtobuf: 6ef3f0e422ef90d6605ca20b21a94f6c1324d6b3 + url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de + video_player_avfoundation: e489aac24ef5cf7af82702979ed16f2a5ef84cff + wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f + webview_flutter_wkwebview: b7e70ef1ddded7e69c796c7390ee74180182971f + zendesk_flutter: 05309cda7bef056d2352fdad933928e281495080 + ZendeskCommonUISDK: ba160fe413b491af9e7bfcb9808afcd494dc83a5 + ZendeskCoreSDK: 4236eb56f9386cf0770900df04c857b9b4d79d03 + ZendeskMessagingAPISDK: 410f9bcf07c79fe98d6f251da102368d6b356c54 + ZendeskMessagingSDK: 95d396c981dacfab83cc7b9736e8561d51a3052b + ZendeskSDKConfigurationsSDK: ebced171fd1f4eb57760e8537d8cfa6a450122be + ZendeskSupportProvidersSDK: 77a62fe6bacc05bb10ff20edce75612fa109fd61 + ZendeskSupportSDK: ba72e90e327635b5fde3d023a3de33242a6ee8ab + +PODFILE CHECKSUM: f445ed5f4cfd131e5c9ec1b15083415fe17f60b9 + +COCOAPODS: 1.11.2 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 5f2c3a39..1e3a886e 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -9,10 +9,10 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 570FC85A20AD0F7716BAF470 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 20546FC7B837C397388AFBD4 /* Pods_Runner.framework */; }; 5DB7F2E0277E375900A4F92F /* ZendeskApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DB7F2DF277E375900A4F92F /* ZendeskApi.swift */; }; 5DC4269926280B9500B25A21 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 5DC4269826280B9500B25A21 /* GoogleService-Info.plist */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; - 74EC80B1A7B6DFB8E07EE7A9 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 051B864B9B383CFA78184163 /* Pods_Runner.framework */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; @@ -32,19 +32,17 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 051B864B9B383CFA78184163 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; - 214E79B4814A6CD2004EBB5E /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + 20546FC7B837C397388AFBD4 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + 25931371E1F9DA5E8BD12458 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 5D69637D2600695B00CC4B17 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; }; 5DB7F2DF277E375900A4F92F /* ZendeskApi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZendeskApi.swift; sourceTree = ""; }; 5DC4269826280B9500B25A21 /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = ""; }; - 69721FFCC1C6C6AEF9B36E22 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; - 7C718B24EE75309D7B92D7C0 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -52,6 +50,8 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + B480DE7D6E14F263FC785CF2 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; + CB9584D1A14A71107ED1A3BE /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -59,29 +59,29 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 74EC80B1A7B6DFB8E07EE7A9 /* Pods_Runner.framework in Frameworks */, + 570FC85A20AD0F7716BAF470 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 5A1F3AD234E9B00E8E63B7B1 /* Pods */ = { + 21E14D9A8F7008DB518E82E1 /* Frameworks */ = { isa = PBXGroup; children = ( - 7C718B24EE75309D7B92D7C0 /* Pods-Runner.debug.xcconfig */, - 214E79B4814A6CD2004EBB5E /* Pods-Runner.release.xcconfig */, - 69721FFCC1C6C6AEF9B36E22 /* Pods-Runner.profile.xcconfig */, + 20546FC7B837C397388AFBD4 /* Pods_Runner.framework */, ); - path = Pods; + name = Frameworks; sourceTree = ""; }; - 8DDC2827CF1865016BC0FD5E /* Frameworks */ = { + 5A1F3AD234E9B00E8E63B7B1 /* Pods */ = { isa = PBXGroup; children = ( - 051B864B9B383CFA78184163 /* Pods_Runner.framework */, + B480DE7D6E14F263FC785CF2 /* Pods-Runner.debug.xcconfig */, + 25931371E1F9DA5E8BD12458 /* Pods-Runner.release.xcconfig */, + CB9584D1A14A71107ED1A3BE /* Pods-Runner.profile.xcconfig */, ); - name = Frameworks; + path = Pods; sourceTree = ""; }; 9740EEB11CF90186004384FC /* Flutter */ = { @@ -102,7 +102,7 @@ 97C146F01CF9000F007C117D /* Runner */, 97C146EF1CF9000F007C117D /* Products */, 5A1F3AD234E9B00E8E63B7B1 /* Pods */, - 8DDC2827CF1865016BC0FD5E /* Frameworks */, + 21E14D9A8F7008DB518E82E1 /* Frameworks */, ); sourceTree = ""; }; @@ -139,14 +139,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - 310731D548D112B5813A6670 /* [CP] Check Pods Manifest.lock */, + 2C251AD5B7FD1DF4F3DCD293 /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 660B8091663088306413AFD2 /* [CP] Embed Pods Frameworks */, + F100DEE7FCF6BB55D63853F0 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -206,7 +206,7 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 310731D548D112B5813A6670 /* [CP] Check Pods Manifest.lock */ = { + 2C251AD5B7FD1DF4F3DCD293 /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -242,36 +242,36 @@ shellPath = /bin/sh; shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; - 660B8091663088306413AFD2 /* [CP] Embed Pods Frameworks */ = { + 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", + inputPaths = ( ); - name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( - "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", + name = "Run Script"; + outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; - showEnvVarsInLog = 0; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; }; - 9740EEB61CF901F6004384FC /* Run Script */ = { + F100DEE7FCF6BB55D63853F0 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); - inputPaths = ( + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist", ); - name = "Run Script"; - outputPaths = ( + name = "[CP] Embed Pods Frameworks"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; + showEnvVarsInLog = 0; }; /* End PBXShellScriptBuildPhase section */ diff --git a/lib/src/config/config_log.dart b/lib/src/config/config_log.dart index 4efbf961..fdc1f93c 100644 --- a/lib/src/config/config_log.dart +++ b/lib/src/config/config_log.dart @@ -3,25 +3,29 @@ * MIT license. See LICENSE file in root directory. */ +import 'dart:io'; + import 'package:flutter/foundation.dart'; import 'package:logging/logging.dart'; import 'package:sentry_flutter/sentry_flutter.dart'; +import 'package:path_provider/path_provider.dart'; import 'config_sentry.dart'; -//ignore_for_file: avoid_print class ConfigLog { - ConfigLog() { + + Future init() async { Logger.root.level = kDebugMode ? Level.ALL : Level.INFO; Logger.root.onRecord.listen(onRecord); + await _rotateLog(); } Future onRecord(LogRecord record) async { if (kDebugMode) { - _print(record); + print(logMessage(record)); } else { if (record.level >= Level.INFO) { - await _saveLog(record); + await _writeLogFile("${logMessage(record)} - ${record.error.toString()}"); if (record.level >= Level.SEVERE) { ConfigSentry.exception(record.message, stackTrace: record.stackTrace); } else if (record.level >= Level.WARNING) { @@ -34,19 +38,13 @@ class ConfigLog { } String _formatTime(DateTime timestamp) { - return timestamp.day.toString().padLeft(2, '0') + - '/' + - timestamp.month.toString().padLeft(2, '0') + - '/' + - timestamp.year.toString().replaceRange(0, 2, '') + - " " + - timestamp.hour.toString().padLeft(2, '0') + - ":" + - timestamp.minute.toString().padLeft(2, '0') + - ":" + - timestamp.second.toString().padLeft(2, '0') + - "." + - timestamp.millisecond.toString().padRight(3, '0'); + return "${timestamp.day.toString().padLeft(2, '0')}/" + "${timestamp.month.toString().padLeft(2, '0')}/" + "${timestamp.year.toString().replaceRange(0, 2, '')} " + "${timestamp.hour.toString().padLeft(2, '0')}:" + "${timestamp.minute.toString().padLeft(2, '0')}:" + "${timestamp.second.toString().padLeft(2, '0')}." + "${timestamp.millisecond.toString().padRight(3, '0')}"; } SentryLevel _toSentryLevel(Level level) { @@ -63,12 +61,51 @@ class ConfigLog { } } - void _print(LogRecord record) { - print( - '${_formatTime(record.time)}: ${record.level.name} [${record.loggerName}] ${record.message}'); + String logMessage(LogRecord record) => + "${_formatTime(record.time)}: ${record.level.name} " + "[${record.loggerName}] ${record.message}"; + + Future _writeLogFile(String log) async { + String path = await _logPath; + String filename = _logFileName; + File file = File('$path/$filename'); + file.writeAsStringSync("$log\n", mode: FileMode.append); + } + + Future get _logPath async { + Directory directory = await getApplicationDocumentsDirectory(); + return directory.path; + } + + String get _logFileName { + DateTime now = DateTime.now(); + return "${now.year.toString()}${now.month.toString().padLeft(2, '0')}${ + now.day.toString().padLeft(2, '0')}.log"; } - Future _saveLog(LogRecord record) async { - // TODO create in-device log + int get _rotateDate { + DateTime now = DateTime.now().subtract(const Duration(days: 15)); + return int.parse("${now.year.toString()}${now.month.toString().padLeft(2, '0')}${ + now.day.toString().padLeft(2, '0')}"); + } + + Future _rotateLog() async{ + String path = await _logPath; + Directory dir = Directory(path); + List files = (await dir.list().toList()).whereType().toList(); + for (File file in files) { + if(file.path.endsWith('log')){ + String filename = file.path.split(Platform.pathSeparator).last; + if(filename == _logFileName && file.lengthSync() > 1000000){ + String newPath = "$path${Platform.pathSeparator}$filename.1"; + await file.rename(newPath); + continue; + } + int fileDate = int.parse(filename.replaceFirst(".log.1", "").replaceFirst(".log", "")); + if(fileDate < _rotateDate){ + await file.delete(); + } + } + } } } diff --git a/pubspec.lock b/pubspec.lock index cff95725..91dda02e 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -450,7 +450,7 @@ packages: source: hosted version: "2.0.2" package_info_plus: - dependency: transitive + dependency: "direct main" description: name: package_info_plus url: "https://pub.dartlang.org" @@ -513,7 +513,7 @@ packages: source: hosted version: "1.0.0" path_provider: - dependency: transitive + dependency: "direct main" description: name: path_provider url: "https://pub.dartlang.org" @@ -672,14 +672,14 @@ packages: name: sentry url: "https://pub.dartlang.org" source: hosted - version: "6.6.1" + version: "6.6.3" sentry_flutter: dependency: "direct main" description: name: sentry_flutter url: "https://pub.dartlang.org" source: hosted - version: "6.6.1" + version: "6.6.3" share_plus: dependency: transitive description: @@ -868,7 +868,7 @@ packages: name: tiki_data url: "https://pub.dartlang.org" source: hosted - version: "0.0.13" + version: "0.0.15" tiki_decision: dependency: "direct main" description: @@ -924,14 +924,14 @@ packages: name: tiki_strategy_google url: "https://pub.dartlang.org" source: hosted - version: "0.1.5" + version: "0.1.7" tiki_strategy_microsoft: dependency: transitive description: name: tiki_strategy_microsoft url: "https://pub.dartlang.org" source: hosted - version: "0.1.5" + version: "0.1.6" tiki_style: dependency: "direct main" description: @@ -945,7 +945,7 @@ packages: name: tiki_syncchain url: "https://pub.dartlang.org" source: hosted - version: "0.0.9" + version: "0.0.10" tiki_upvoty: dependency: transitive description: @@ -966,7 +966,7 @@ packages: name: tiki_wallet url: "https://pub.dartlang.org" source: hosted - version: "0.0.25" + version: "0.0.26" tuple: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 1090336d..2ce9d2b0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: app description: It's your data. Take back control. -version: 0.4.2+2 +version: 0.4.3 publish_to: 'none' environment: @@ -18,8 +18,10 @@ dependencies: intl: ^0.17.0 logging: ^1.0.2 provider: ^6.0.3 + path_provider: ^2.0.11 + package_info_plus: ^1.4.2 shared_preferences: ^2.0.15 - sentry_flutter: ^6.6.2 + sentry_flutter: ^6.6.3 sqflite_sqlcipher: ^2.1.1 httpp: ^0.0.6 tiki_decision: ^0.0.13 @@ -31,7 +33,7 @@ dependencies: tiki_money: ^0.0.11 tiki_style: ^0.0.20 tiki_localgraph: ^0.0.7 - tiki_data: ^0.0.14 + tiki_data: ^0.0.15 dependency_overrides: sqflite: @@ -44,7 +46,6 @@ dependency_overrides: flutter_math_fork: ^0.6.3 # remove errors from console flutter_svg: ^1.0.0 # solve conflict between flutter_math_fork and flutter_html - dev_dependencies: flutter_test: sdk: flutter