AOSSIE-Org / AOSSIE-Org/Resonate

`refactor: Replace print() statement with proper logging in whisper_transcription_controller`

未关闭
#680 3 条评论 0 个 reaction 已指派 1 人 已被 @YadavAkhileshh 认领 在 GitHub 查看
enhancement good first issue
主要语言
Dart
星标
344
派生
350
PR 合并指标
30 天内没有已合并 PR

描述

## Description
The `whisper_transcription_controller.dart` file has two logging/error handling issues:
1. Line 71: Using `print()` instead of proper logging
2. Lines 62-73: Generic error handling without context or stack trace

## Current Issues

### Issue 1: Using print() instead of log()
```dart
} catch (e) {
print(e.toString());
}
```

### Issue 2: Poor error handling in loop (Lines 62-73)
```dart
for (WhisperTranscribeSegment? segment in transcriptionSegments) {
try {
final segmentString = _parseTranscriptionSegment(segment);
if (segmentString != null) {
lrcContent.writeln(segmentString);
}
} catch (e) {
print(e.toString()); // No context, no stack trace
}
}
```

## Problems
1. Using `print()` instead of `log()` (file already imports `dart:developer`)
2. Inconsistent logging (rest of file uses `log()`)
3. No context about which segment failed
4. No stack trace for debugging
5. Silently continues without proper error reporting

## Proposed Solution

### Fix 1: Replace print() with log()
```dart
} catch (e) {
log('Error converting transcription segment: ${e.toString()}');
}
```

### Fix 2: Improve error handling with context
```dart
for (int i = 0; i < transcriptionSegments.length; i++) {
try {
final segment = transcriptionSegments[i];
final segmentString = _parseTranscriptionSegment(segment);
if (segmentString != null) {
lrcContent.writeln(segmentString);
}
} catch (e, stackTrace) {
log(
'Error converting transcription segment at index $i: ${e.toString()}',
error: e,
stackTrace: stackTrace,
);
......
}
}
```

## Benefits
- Consistent logging throughout the file
- Better debugging with segment index
- Proper stack traces for error diagnosis
- Follows Flutter best practices
- More maintainable code

## Files to Change
- `lib/controllers/whisper_transcription_controller.dart` (2 locations)

## I would like to work on this

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。