mirror of
https://ghfast.top/https://github.com/StarCitizenToolBox/app.git
synced 2025-06-29 08:05:39 +08:00
output log to files
This commit is contained in:
19
lib/common/utils/log.dart
Normal file
19
lib/common/utils/log.dart
Normal file
@ -0,0 +1,19 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:synchronized/synchronized.dart';
|
||||
|
||||
import '../conf/app_conf.dart';
|
||||
|
||||
var _logLock = Lock();
|
||||
|
||||
void dPrint(src) async {
|
||||
if (kDebugMode) {
|
||||
print(src);
|
||||
}
|
||||
try {
|
||||
await _logLock.synchronized(() async {
|
||||
await AppConf.appLogFile?.writeAsString("$src\n", mode: FileMode.append);
|
||||
});
|
||||
} catch (_) {}
|
||||
}
|
Reference in New Issue
Block a user