2024-03-01 20:59:43 +08:00
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
import 'package:synchronized/synchronized.dart';
|
|
|
|
|
2024-03-15 00:01:06 +08:00
|
|
|
export 'package:starcitizen_doctor/generated/l10n.dart';
|
|
|
|
|
2024-03-01 20:59:43 +08:00
|
|
|
var _logLock = Lock();
|
2024-03-07 23:01:32 +08:00
|
|
|
File? _logFile;
|
2024-03-01 20:59:43 +08:00
|
|
|
|
|
|
|
void dPrint(src) async {
|
|
|
|
if (kDebugMode) {
|
|
|
|
print(src);
|
|
|
|
}
|
2024-03-23 17:53:42 +08:00
|
|
|
await _logLock.synchronized(() async {
|
|
|
|
try {
|
2024-03-23 17:54:32 +08:00
|
|
|
await _logFile?.writeAsString("$src\n", mode: FileMode.append);
|
2024-03-23 17:53:42 +08:00
|
|
|
} catch (_) {}
|
|
|
|
});
|
2024-03-01 20:59:43 +08:00
|
|
|
}
|
2024-03-07 23:01:32 +08:00
|
|
|
|
|
|
|
void setDPrintFile(File file) {
|
|
|
|
_logFile = file;
|
|
|
|
}
|
2024-03-10 19:44:53 +08:00
|
|
|
|
|
|
|
File? getDPrintFile() {
|
|
|
|
return _logFile;
|
|
|
|
}
|