improve logging

This commit is contained in:
otsmr 2025-11-30 12:27:21 +01:00
parent 9cb2503cdb
commit 108a58ffe1
7 changed files with 10 additions and 18 deletions

View file

@ -185,7 +185,7 @@ class ApiService {
}
Future<void> _onError(dynamic e) async {
Log.error('websocket error: $e');
Log.warn('websocket error: $e');
await onClosed();
}
@ -206,7 +206,7 @@ class ApiService {
Future<server.ServerToClient?> _waitForResponse(Int64 seq) async {
final startTime = DateTime.now();
const timeout = Duration(seconds: 20);
const timeout = Duration(seconds: 60);
while (true) {
if (messagesV0[seq] != null) {
@ -215,7 +215,7 @@ class ApiService {
return tmp;
}
if (DateTime.now().difference(startTime) > timeout) {
Log.error('Timeout for message $seq');
Log.warn('Timeout for message $seq');
return null;
}
await Future.delayed(const Duration(milliseconds: 10));
@ -417,7 +417,7 @@ class ApiService {
final result = await sendRequestSync(req, authenticated: false);
if (result.isError) {
Log.error('could not request auth challenge', result);
Log.warn('could not request auth challenge', result);
return;
}

View file

@ -112,7 +112,6 @@ Future<void> handleDownloadStatusUpdate(TaskStatusUpdate update) async {
}
if (failed) {
Log.error('Background media upload failed: ${update.status}');
await requestMediaReupload(mediaId);
} else {
await handleEncryptedFile(mediaId);

View file

@ -35,11 +35,7 @@ class MediaFileService {
final service = await MediaFileService.fromMediaId(mediaId);
if (service == null) {
Log.error(
'Purging media file, as it is not in the database $mediaId.',
);
} else {
if (service != null) {
if (service.mediaFile.isDraftMedia) {
delete = false;
}

View file

@ -112,7 +112,7 @@ Future<(EncryptedContent?, PlaintextContent_DecryptionErrorMessage_Type?)>
return (EncryptedContent.fromBuffer(plaintext), null);
} on InvalidKeyIdException catch (e) {
Log.error(e);
Log.warn(e);
return (null, PlaintextContent_DecryptionErrorMessage_Type.PREKEY_UNKNOWN);
} catch (e) {
Log.error(e);

View file

@ -50,8 +50,7 @@ Future<void> requestNewPrekeysForContact(int contactId) async {
.toList();
await twonlyDB.signalDao.insertPreKeys(preKeys);
} else {
// 104400
Log.error('[PREKEY] Could not load new pre keys for user $contactId');
Log.warn('[PREKEY] Could not load new pre keys for user $contactId');
}
});
}
@ -85,7 +84,7 @@ Future<void> requestNewSignedPreKeyForContact(int contactId) async {
),
);
} else {
Log.error('could not load new signed pre key for user $contactId');
Log.warn('could not load new signed pre key for user $contactId');
}
});
}

View file

@ -23,9 +23,9 @@ void initLogger() {
class Log {
static String filterLogMessage(String msg) {
if (msg.contains("SqliteException")) {
if (msg.contains('SqliteException')) {
// Do not log data which would be inserted into the DB.
return msg.substring(0, msg.indexOf("parameters: "));
return msg.substring(0, msg.indexOf('parameters: '));
}
return msg;
}

View file

@ -6,7 +6,6 @@ import 'dart:math';
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';
import 'package:twonly/globals.dart';
import 'package:twonly/src/utils/log.dart';
import 'package:twonly/src/views/camera/camera_preview_controller_view.dart';
class CameraZoomButtons extends StatefulWidget {
@ -51,7 +50,6 @@ class _CameraZoomButtonsState extends State<CameraZoomButtons> {
Future<void> initAsync() async {
showWideAngleZoom = (await widget.controller.getMinZoomLevel()) < 1;
Log.info('Found ${gCameras.length} cameras for zoom.');
var index =
gCameras.indexWhere((t) => t.lensType == CameraLensType.ultraWide);