Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Refine log filtering for isolate output

Priyanshu Dangare4f2e1718a071
diff --git a/mobile/apps/photos/lib/core/error-reporting/isolate_logging.dart b/mobile/apps/photos/lib/core/error-reporting/isolate_logging.dart
index 0377f3a36e..76a4f7e8da 100644
--- a/mobile/apps/photos/lib/core/error-reporting/isolate_logging.dart
+++ b/mobile/apps/photos/lib/core/error-reporting/isolate_logging.dart
@@ -57,12 +57,12 @@ class IsolateLogger {
final Queue<IsolateLogString> fileQueueEntries = Queue();
Future onLogRecordInIsolate(LogRecord rec) async {
- if (!SuperLogging.shouldLogRecord(rec)) return;
-
final str = rec.toPrettyString(null, true);
// write to stdout
- SuperLogging.printLog(str);
+ if (SuperLogging.shouldPrintLogRecord(rec)) {
+ SuperLogging.printLog(str);
+ }
// push to log queue
fileQueueEntries.add(
diff --git a/mobile/apps/photos/lib/core/error-reporting/super_logging.dart b/mobile/apps/photos/lib/core/error-reporting/super_logging.dart
index 0063ce984e..111123fa4e 100644
--- a/mobile/apps/photos/lib/core/error-reporting/super_logging.dart
+++ b/mobile/apps/photos/lib/core/error-reporting/super_logging.dart
@@ -412,7 +412,9 @@ class SuperLogging {
static String _lastExtraLines = '';
- static final Level rootLoggerLevel =
+ static const Level rootLoggerLevel = kDebugMode ? Level.ALL : Level.INFO;
+
+ static final Level _terminalLoggerLevel =
Level.LEVELS
.where(
(level) =>
@@ -422,16 +424,16 @@ class SuperLogging {
).trim().toLowerCase(),
)
.firstOrNull ??
- (kDebugMode ? Level.ALL : Level.INFO);
+ rootLoggerLevel;
- static bool shouldLogRecord(LogRecord rec) {
- return _loggerPrefixDefine.isEmpty ||
+ static bool shouldPrintLogRecord(LogRecord rec) {
+ final matchesPrefix =
+ _loggerPrefixDefine.isEmpty ||
rec.loggerName.toLowerCase().startsWith(_loggerPrefixDefine);
+ return matchesPrefix && rec.level.value >= _terminalLoggerLevel.value;
}
static Future onLogRecord(LogRecord rec) async {
- if (!shouldLogRecord(rec)) return;
-
// log misc info if it changed
String? extraLines = "app version: '$appVersion'\n";
if (extraLines != _lastExtraLines) {
@@ -443,7 +445,9 @@ class SuperLogging {
final str = (config.prefix) + " " + rec.toPrettyString(extraLines);
// write to stdout
- printLog(str);
+ if (shouldPrintLogRecord(rec)) {
+ printLog(str);
+ }
saveLogString(str, rec.error, rec: rec);
}