Committed by
GitHub
Merge pull request #516 from jorgegaticav/master
improvement of logging, replaced print method for developer.log
Showing
4 changed files
with
23 additions
and
21 deletions
1 | + | ||
1 | import 'package:get/instance_manager.dart'; | 2 | import 'package:get/instance_manager.dart'; |
3 | +import 'dart:developer' as developer; | ||
2 | 4 | ||
3 | typedef LogWriterCallback = void Function(String text, {bool isError}); | 5 | typedef LogWriterCallback = void Function(String text, {bool isError}); |
4 | 6 | ||
5 | void defaultLogWriterCallback(String value, {bool isError = false}) { | 7 | void defaultLogWriterCallback(String value, {bool isError = false}) { |
6 | - if (isError || GetConfig.isLogEnable) print(value); | 8 | + if (isError || GetConfig.isLogEnable) developer.log(value, name: 'GETX'); |
7 | } | 9 | } |
1 | +import 'package:flutter/cupertino.dart'; | ||
1 | import 'package:get/src/core/log.dart'; | 2 | import 'package:get/src/core/log.dart'; |
2 | import 'package:get/src/navigation/root/smart_management.dart'; | 3 | import 'package:get/src/navigation/root/smart_management.dart'; |
3 | import 'package:get/src/state_manager/rx/rx_interface.dart'; | 4 | import 'package:get/src/state_manager/rx/rx_interface.dart'; |
@@ -127,7 +128,7 @@ class GetInstance { | @@ -127,7 +128,7 @@ class GetInstance { | ||
127 | 128 | ||
128 | if (i is DisposableInterface) { | 129 | if (i is DisposableInterface) { |
129 | i.onStart(); | 130 | i.onStart(); |
130 | - GetConfig.log('[GETX] $key has been initialized'); | 131 | + GetConfig.log('$key has been initialized'); |
131 | } | 132 | } |
132 | } | 133 | } |
133 | 134 | ||
@@ -172,7 +173,7 @@ class GetInstance { | @@ -172,7 +173,7 @@ class GetInstance { | ||
172 | if (!_factory.containsKey(key)) | 173 | if (!_factory.containsKey(key)) |
173 | throw " $S not found. You need call put<$S>($S()) before"; | 174 | throw " $S not found. You need call put<$S>($S()) before"; |
174 | 175 | ||
175 | - GetConfig.log('[GETX] $S instance was created at that time'); | 176 | + GetConfig.log('$S instance was created at that time'); |
176 | S _value = put<S>(_factory[key].builder() as S); | 177 | S _value = put<S>(_factory[key].builder() as S); |
177 | 178 | ||
178 | initDependencies<S>(name: tag); | 179 | initDependencies<S>(name: tag); |
@@ -216,15 +217,14 @@ class GetInstance { | @@ -216,15 +217,14 @@ class GetInstance { | ||
216 | 217 | ||
217 | return queue.add<bool>(() async { | 218 | return queue.add<bool>(() async { |
218 | if (!_singl.containsKey(newKey)) { | 219 | if (!_singl.containsKey(newKey)) { |
219 | - GetConfig.log('[GETX] Instance $newKey already been removed.', | ||
220 | - isError: true); | 220 | + GetConfig.log('Instance $newKey already been removed.', isError: true); |
221 | return false; | 221 | return false; |
222 | } | 222 | } |
223 | 223 | ||
224 | FcBuilder builder = _singl[newKey] as FcBuilder; | 224 | FcBuilder builder = _singl[newKey] as FcBuilder; |
225 | if (builder.permanent && !force) { | 225 | if (builder.permanent && !force) { |
226 | GetConfig.log( | 226 | GetConfig.log( |
227 | - '[GETX] [$newKey] has been marked as permanent, SmartManagement is not authorized to delete it.', | 227 | + '[$newKey] has been marked as permanent, SmartManagement is not authorized to delete it.', |
228 | isError: true); | 228 | isError: true); |
229 | return false; | 229 | return false; |
230 | } | 230 | } |
@@ -235,14 +235,14 @@ class GetInstance { | @@ -235,14 +235,14 @@ class GetInstance { | ||
235 | } | 235 | } |
236 | if (i is DisposableInterface) { | 236 | if (i is DisposableInterface) { |
237 | await i.onClose(); | 237 | await i.onClose(); |
238 | - GetConfig.log('[GETX] onClose of $newKey called'); | 238 | + GetConfig.log('onClose of $newKey called'); |
239 | } | 239 | } |
240 | 240 | ||
241 | _singl.removeWhere((oldKey, value) => (oldKey == newKey)); | 241 | _singl.removeWhere((oldKey, value) => (oldKey == newKey)); |
242 | if (_singl.containsKey(newKey)) { | 242 | if (_singl.containsKey(newKey)) { |
243 | - GetConfig.log('[GETX] error on remove object $newKey', isError: true); | 243 | + GetConfig.log('error on remove object $newKey', isError: true); |
244 | } else { | 244 | } else { |
245 | - GetConfig.log('[GETX] $newKey deleted from memory'); | 245 | + GetConfig.log('$newKey deleted from memory'); |
246 | } | 246 | } |
247 | // _routesKey?.remove(key); | 247 | // _routesKey?.remove(key); |
248 | return true; | 248 | return true; |
@@ -72,13 +72,13 @@ class GetObserver extends NavigatorObserver { | @@ -72,13 +72,13 @@ class GetObserver extends NavigatorObserver { | ||
72 | String routeName = name(route); | 72 | String routeName = name(route); |
73 | 73 | ||
74 | if (isSnackbar) { | 74 | if (isSnackbar) { |
75 | - GetConfig.log("[GETX] OPEN SNACKBAR $routeName"); | 75 | + GetConfig.log("OPEN SNACKBAR $routeName"); |
76 | } else if (isBottomSheet) { | 76 | } else if (isBottomSheet) { |
77 | - GetConfig.log("[GETX] OPEN $routeName"); | 77 | + GetConfig.log("OPEN $routeName"); |
78 | } else if (isDialog) { | 78 | } else if (isDialog) { |
79 | - GetConfig.log("[GETX] OPEN $routeName"); | 79 | + GetConfig.log("OPEN $routeName"); |
80 | } else if (isGetPageRoute) { | 80 | } else if (isGetPageRoute) { |
81 | - GetConfig.log("[GETX] GOING TO ROUTE $routeName"); | 81 | + GetConfig.log("GOING TO ROUTE $routeName"); |
82 | } | 82 | } |
83 | GetConfig.currentRoute = routeName; | 83 | GetConfig.currentRoute = routeName; |
84 | 84 | ||
@@ -107,13 +107,13 @@ class GetObserver extends NavigatorObserver { | @@ -107,13 +107,13 @@ class GetObserver extends NavigatorObserver { | ||
107 | String routeName = name(route); | 107 | String routeName = name(route); |
108 | 108 | ||
109 | if (isSnackbar) { | 109 | if (isSnackbar) { |
110 | - GetConfig.log("[GETX] CLOSE SNACKBAR $routeName"); | 110 | + GetConfig.log("CLOSE SNACKBAR $routeName"); |
111 | } else if (isBottomSheet) { | 111 | } else if (isBottomSheet) { |
112 | - GetConfig.log("[GETX] CLOSE $routeName"); | 112 | + GetConfig.log("CLOSE $routeName"); |
113 | } else if (isDialog) { | 113 | } else if (isDialog) { |
114 | - GetConfig.log("[GETX] CLOSE $routeName"); | 114 | + GetConfig.log("CLOSE $routeName"); |
115 | } else if (isGetPageRoute) { | 115 | } else if (isGetPageRoute) { |
116 | - GetConfig.log("[GETX] CLOSE TO ROUTE $routeName"); | 116 | + GetConfig.log("CLOSE TO ROUTE $routeName"); |
117 | } | 117 | } |
118 | GetConfig.currentRoute = routeName; | 118 | GetConfig.currentRoute = routeName; |
119 | 119 | ||
@@ -136,8 +136,8 @@ class GetObserver extends NavigatorObserver { | @@ -136,8 +136,8 @@ class GetObserver extends NavigatorObserver { | ||
136 | void didReplace({Route newRoute, Route oldRoute}) { | 136 | void didReplace({Route newRoute, Route oldRoute}) { |
137 | super.didReplace(newRoute: newRoute, oldRoute: oldRoute); | 137 | super.didReplace(newRoute: newRoute, oldRoute: oldRoute); |
138 | 138 | ||
139 | - GetConfig.log("[GETX] REPLACE ROUTE ${oldRoute?.settings?.name}"); | ||
140 | - GetConfig.log("[GETX] NEW ROUTE ${newRoute?.settings?.name}"); | 139 | + GetConfig.log("REPLACE ROUTE ${oldRoute?.settings?.name}"); |
140 | + GetConfig.log("NEW ROUTE ${newRoute?.settings?.name}"); | ||
141 | 141 | ||
142 | GetConfig.currentRoute = name(newRoute); | 142 | GetConfig.currentRoute = name(newRoute); |
143 | 143 | ||
@@ -158,7 +158,7 @@ class GetObserver extends NavigatorObserver { | @@ -158,7 +158,7 @@ class GetObserver extends NavigatorObserver { | ||
158 | @override | 158 | @override |
159 | void didRemove(Route route, Route previousRoute) { | 159 | void didRemove(Route route, Route previousRoute) { |
160 | super.didRemove(route, previousRoute); | 160 | super.didRemove(route, previousRoute); |
161 | - GetConfig.log("[GETX] REMOVING ROUTE ${route?.settings?.name}"); | 161 | + GetConfig.log("REMOVING ROUTE ${route?.settings?.name}"); |
162 | 162 | ||
163 | _routeSend.update((value) { | 163 | _routeSend.update((value) { |
164 | value.route = previousRoute; | 164 | value.route = previousRoute; |
@@ -100,7 +100,7 @@ class Worker { | @@ -100,7 +100,7 @@ class Worker { | ||
100 | final String type; | 100 | final String type; |
101 | 101 | ||
102 | void _message() { | 102 | void _message() { |
103 | - GetConfig.log('[Getx] Worker $type disposed'); | 103 | + GetConfig.log('Worker $type disposed'); |
104 | } | 104 | } |
105 | 105 | ||
106 | void dispose() { | 106 | void dispose() { |
-
Please register or login to post a comment