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);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
await _logLock.synchronized(() async {
|
2024-03-07 23:01:32 +08:00
|
|
|
_logFile?.writeAsString("$src\n", mode: FileMode.append);
|
2024-03-01 20:59:43 +08:00
|
|
|
});
|
|
|
|
} catch (_) {}
|
|
|
|
}
|
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;
|
|
|
|
}
|