mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-06-30 22:20:30 +10:00
Add advanced path management, debug logging, and fix channel sync
New features: - In-app debug log viewer with copy/clear functionality - Advanced path management UI with history and custom path builder - Battery indicator widget with voltage/percentage toggle - Contact/channel filtering and sorting improvements - Repeater command ACK tracking with path history integration Fixes: - Switch channel sync from parallel to sequential to prevent timeouts - Preserve path overrides when contacts refresh from device - Fix ACK hash computation for SMAZ-encoded messages - Proper cleanup of pending operations on disconnect
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
enum AppDebugLogLevel {
|
||||
info,
|
||||
warning,
|
||||
error,
|
||||
}
|
||||
|
||||
class AppDebugLogEntry {
|
||||
final DateTime timestamp;
|
||||
final AppDebugLogLevel level;
|
||||
final String tag;
|
||||
final String message;
|
||||
|
||||
AppDebugLogEntry({
|
||||
required this.timestamp,
|
||||
required this.level,
|
||||
required this.tag,
|
||||
required this.message,
|
||||
});
|
||||
|
||||
String get levelLabel {
|
||||
switch (level) {
|
||||
case AppDebugLogLevel.info:
|
||||
return 'INFO';
|
||||
case AppDebugLogLevel.warning:
|
||||
return 'WARN';
|
||||
case AppDebugLogLevel.error:
|
||||
return 'ERROR';
|
||||
}
|
||||
}
|
||||
|
||||
String get formattedTime {
|
||||
return '${timestamp.hour.toString().padLeft(2, '0')}:'
|
||||
'${timestamp.minute.toString().padLeft(2, '0')}:'
|
||||
'${timestamp.second.toString().padLeft(2, '0')}.'
|
||||
'${timestamp.millisecond.toString().padLeft(3, '0')}';
|
||||
}
|
||||
}
|
||||
|
||||
class AppDebugLogService extends ChangeNotifier {
|
||||
static const int maxEntries = 1000;
|
||||
final List<AppDebugLogEntry> _entries = [];
|
||||
bool _enabled = false;
|
||||
|
||||
List<AppDebugLogEntry> get entries => List.unmodifiable(_entries);
|
||||
bool get enabled => _enabled;
|
||||
|
||||
void setEnabled(bool value) {
|
||||
_enabled = value;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void log(String message, {String tag = 'App', AppDebugLogLevel level = AppDebugLogLevel.info}) {
|
||||
if (!_enabled) return;
|
||||
|
||||
_entries.add(
|
||||
AppDebugLogEntry(
|
||||
timestamp: DateTime.now(),
|
||||
level: level,
|
||||
tag: tag,
|
||||
message: message,
|
||||
),
|
||||
);
|
||||
|
||||
if (_entries.length > maxEntries) {
|
||||
_entries.removeRange(0, _entries.length - maxEntries);
|
||||
}
|
||||
|
||||
notifyListeners();
|
||||
|
||||
// Also print to console for development
|
||||
debugPrint('[$tag] $message');
|
||||
}
|
||||
|
||||
void info(String message, {String tag = 'App'}) {
|
||||
log(message, tag: tag, level: AppDebugLogLevel.info);
|
||||
}
|
||||
|
||||
void warn(String message, {String tag = 'App'}) {
|
||||
log(message, tag: tag, level: AppDebugLogLevel.warning);
|
||||
}
|
||||
|
||||
void error(String message, {String tag = 'App'}) {
|
||||
log(message, tag: tag, level: AppDebugLogLevel.error);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
_entries.clear();
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user