refactor: 重命名 automation worker 为 general worker 并完善错误处理

This commit is contained in:
qzl
2026-04-01 17:24:52 +08:00
parent 0fe28a1c62
commit 24eda6ff51
19 changed files with 760 additions and 25 deletions
+8 -1
View File
@@ -8,6 +8,7 @@ class LogEntry {
final String? funcName;
final int? lineNo;
final String? errorType;
final String? errorMessage;
final String? stackTrace;
final Map<String, dynamic>? extra;
@@ -19,6 +20,7 @@ class LogEntry {
this.funcName,
this.lineNo,
this.errorType,
this.errorMessage,
this.stackTrace,
this.extra,
});
@@ -31,6 +33,7 @@ class LogEntry {
if (funcName != null) 'func_name': funcName,
if (lineNo != null) 'line_no': lineNo,
if (errorType != null) 'error_type': errorType,
if (errorMessage != null) 'error_message': errorMessage,
if (stackTrace != null) 'stack_trace': stackTrace,
if (extra != null && extra!.isNotEmpty) 'extra': extra,
};
@@ -43,8 +46,9 @@ class LogEntry {
].join('');
final locationStr = location.isNotEmpty ? ' [$location]' : '';
final errorStr = errorType != null ? ' [$errorType]' : '';
final errorMsgStr = errorMessage != null ? ' $errorMessage' : '';
final extraStr = extra != null && extra!.isNotEmpty ? ' $extra' : '';
return '$ts ${level.name.toUpperCase().padRight(7)} [$module$locationStr]$errorStr $message$extraStr';
return '$ts ${level.name.toUpperCase().padRight(7)} [$module$locationStr]$errorStr $message$errorMsgStr$extraStr';
}
String toFileString() {
@@ -59,6 +63,9 @@ class LogEntry {
if (errorType != null) {
sb.writeln(' Error: $errorType');
}
if (errorMessage != null) {
sb.writeln(' ErrorMessage: $errorMessage');
}
if (stackTrace != null) {
sb.writeln(' StackTrace:');
sb.writeln(stackTrace);