feat(logging): add logging to ChatBloc
This commit is contained in:
@@ -4,6 +4,14 @@ part of 'chat_bloc.dart';
|
||||
|
||||
extension _ChatBlocSend on ChatBloc {
|
||||
Future<void> _sendMessage(String content, {List<XFile>? images}) async {
|
||||
_logger.info(
|
||||
message: 'Sending chat message',
|
||||
extra: {
|
||||
'message_length': content.length,
|
||||
'attachments_count': images?.length ?? 0,
|
||||
},
|
||||
);
|
||||
|
||||
final epoch = _sessionEpoch;
|
||||
final assistantBaselineAtSend = chatBlocLatestAssistantTimestamp(
|
||||
state.items,
|
||||
@@ -57,11 +65,21 @@ extension _ChatBlocSend on ChatBloc {
|
||||
if (epoch != _sessionEpoch) {
|
||||
return;
|
||||
}
|
||||
_logger.info(
|
||||
message: 'Chat message sent successfully',
|
||||
extra: {'message_id': messageId},
|
||||
);
|
||||
_syncUploadedAttachments(
|
||||
messageId: messageId,
|
||||
uploadedAttachments: sendResult.uploadedAttachments,
|
||||
);
|
||||
} catch (error) {
|
||||
} catch (error, stackTrace) {
|
||||
_logger.error(
|
||||
message: 'Failed to send chat message',
|
||||
error: error,
|
||||
stackTrace: stackTrace,
|
||||
extra: {'message': content},
|
||||
);
|
||||
if (epoch != _sessionEpoch) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user