mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-06-03 01:52:13 +00:00
Some checks failed
Flutter analyze & test / flutter_analyze_and_test (push) Has been cancelled
33 lines
977 B
Dart
33 lines
977 B
Dart
import 'dart:async';
|
|
import 'dart:io';
|
|
import 'package:flutter/foundation.dart';
|
|
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
|
|
import 'package:twonly/src/utils/log.dart';
|
|
|
|
class LoggingCallbacks {
|
|
static Future<RustStreamSink<String>> getStreamSink() async {
|
|
final dartLogSink = RustStreamSink<String>();
|
|
|
|
Timer.periodic(const Duration(milliseconds: 100), (timer) {
|
|
try {
|
|
dartLogSink.stream.listen(
|
|
(log) {
|
|
if (log.contains('INFO ')) {
|
|
Log.info(log.split('INFO ')[1]);
|
|
} else if (log.contains('DEBUG ')) {
|
|
Log.info(log.split('DEBUG ')[1]);
|
|
} else if (kDebugMode && !Platform.environment.containsKey('FLUTTER_TEST')) {
|
|
// ignore: avoid_print
|
|
print(log);
|
|
}
|
|
},
|
|
);
|
|
timer.cancel();
|
|
} catch (e) {
|
|
// stream not yet initialized
|
|
}
|
|
});
|
|
|
|
return dartLogSink;
|
|
}
|
|
}
|