feat: improve logging and event filtering
- Add HTTP debug logging to TraccarHttpClient (URL, error body) - Route HTTP client logs through app event log system - Fix syncBufferedLocations to properly report partial failures - Add DEBUG event type with separate filter chip - Rename ALL filter to NORMAL, add VERBOSE (shows DEBUG, FILTERED, SPEED_CALC) - Add color/icon for INFO, NETWORK_CHANGE, DEBUG, SPEED_CALC events - Make log message text selectable
This commit is contained in:
parent
60d051ee7b
commit
09009fee4c
3 changed files with 57 additions and 16 deletions
|
|
@ -13,7 +13,7 @@ class StatusScreen extends StatefulWidget {
|
|||
class _StatusScreenState extends State<StatusScreen> {
|
||||
List<Map<String, dynamic>> _logs = [];
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
String _filter = 'ALL';
|
||||
String _filter = 'NORMAL';
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
@ -107,6 +107,8 @@ class _StatusScreenState extends State<StatusScreen> {
|
|||
return const Color(0xFFff5252);
|
||||
case 'WARNING':
|
||||
return const Color(0xFFffb74d);
|
||||
case 'INFO':
|
||||
return const Color(0xFF00bcd4);
|
||||
case 'LOCATION':
|
||||
return const Color(0xFF69f0ae);
|
||||
case 'SYNC':
|
||||
|
|
@ -115,6 +117,12 @@ class _StatusScreenState extends State<StatusScreen> {
|
|||
return const Color(0xFFffe082);
|
||||
case 'FILTERED':
|
||||
return const Color(0xFF546e7a);
|
||||
case 'NETWORK_CHANGE':
|
||||
return const Color(0xFFce93d8);
|
||||
case 'DEBUG':
|
||||
return const Color(0xFF78909c);
|
||||
case 'SPEED_CALC':
|
||||
return const Color(0xFF90a4ae);
|
||||
default:
|
||||
return const Color(0xFF78909c);
|
||||
}
|
||||
|
|
@ -126,6 +134,8 @@ class _StatusScreenState extends State<StatusScreen> {
|
|||
return Icons.close;
|
||||
case 'WARNING':
|
||||
return Icons.warning;
|
||||
case 'INFO':
|
||||
return Icons.info;
|
||||
case 'LOCATION':
|
||||
return Icons.gps_fixed;
|
||||
case 'SYNC':
|
||||
|
|
@ -134,13 +144,34 @@ class _StatusScreenState extends State<StatusScreen> {
|
|||
return Icons.favorite;
|
||||
case 'FILTERED':
|
||||
return Icons.filter_alt;
|
||||
case 'NETWORK_CHANGE':
|
||||
return Icons.signal_wifi_connected_no_internet_4;
|
||||
case 'DEBUG':
|
||||
return Icons.bug_report;
|
||||
case 'SPEED_CALC':
|
||||
return Icons.speed;
|
||||
default:
|
||||
return Icons.info;
|
||||
}
|
||||
}
|
||||
|
||||
static const _normalEventTypes = {
|
||||
'INFO',
|
||||
'LOCATION',
|
||||
'SYNC',
|
||||
'ERROR',
|
||||
'NETWORK_CHANGE',
|
||||
'HEARTBEAT',
|
||||
'WARNING',
|
||||
};
|
||||
|
||||
List<Map<String, dynamic>> get _filteredLogs {
|
||||
if (_filter == 'ALL') return _logs;
|
||||
if (_filter == 'VERBOSE') return _logs;
|
||||
if (_filter == 'NORMAL') {
|
||||
return _logs
|
||||
.where((l) => _normalEventTypes.contains(l['eventType']))
|
||||
.toList();
|
||||
}
|
||||
return _logs.where((l) => l['eventType'] == _filter).toList();
|
||||
}
|
||||
|
||||
|
|
@ -207,13 +238,15 @@ class _StatusScreenState extends State<StatusScreen> {
|
|||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildFilterChip('ALL', null),
|
||||
_buildFilterChip('NORMAL', 'NORMAL'),
|
||||
const SizedBox(width: 8),
|
||||
_buildFilterChip('LOG', 'LOCATION'),
|
||||
_buildFilterChip('LOCATION', 'LOCATION'),
|
||||
const SizedBox(width: 8),
|
||||
_buildFilterChip('SYNC', 'SYNC'),
|
||||
const SizedBox(width: 8),
|
||||
_buildFilterChip('ERR', 'ERROR'),
|
||||
const SizedBox(width: 8),
|
||||
_buildFilterChip('DEBUG', 'DEBUG'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
@ -231,7 +264,7 @@ class _StatusScreenState extends State<StatusScreen> {
|
|||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
_filter == 'ALL'
|
||||
_filter == 'VERBOSE'
|
||||
? 'No events recorded'
|
||||
: 'No $_filter events',
|
||||
style: const TextStyle(
|
||||
|
|
@ -268,10 +301,10 @@ class _StatusScreenState extends State<StatusScreen> {
|
|||
);
|
||||
}
|
||||
|
||||
Widget _buildFilterChip(String label, String? eventType) {
|
||||
final isSelected = _filter == (eventType ?? 'ALL');
|
||||
Widget _buildFilterChip(String label, String eventType) {
|
||||
final isSelected = _filter == eventType;
|
||||
return GestureDetector(
|
||||
onTap: () => setState(() => _filter = eventType ?? 'ALL'),
|
||||
onTap: () => setState(() => _filter = eventType),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
|
|
@ -362,7 +395,7 @@ class _StatusScreenState extends State<StatusScreen> {
|
|||
),
|
||||
const SizedBox(height: 5),
|
||||
// Line 2: message
|
||||
Text(
|
||||
SelectableText(
|
||||
msg,
|
||||
style: const TextStyle(
|
||||
fontFamily: 'monospace',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue