mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-12-23 10:11:52 +03:00
Fix "--log-level" argument which wasn't working correctly.
This commit is contained in:
parent
10f46ec478
commit
51a76f686d
@ -45,7 +45,7 @@ void main() {
|
||||
testWidgets('Add account', (WidgetTester tester) async {
|
||||
final Widget initializedApp;
|
||||
if (isDesktop) {
|
||||
initializedApp = await desktop.initialize();
|
||||
initializedApp = await desktop.initialize([]);
|
||||
} else if (isAndroid) {
|
||||
initializedApp = await android.initialize();
|
||||
} else {
|
||||
|
@ -39,8 +39,8 @@ class _WindowResizeListener extends WindowListener {
|
||||
}
|
||||
}
|
||||
|
||||
Future<Widget> initialize() async {
|
||||
_initLogging();
|
||||
Future<Widget> initialize(List<String> argv) async {
|
||||
_initLogging(argv);
|
||||
|
||||
await windowManager.ensureInitialized();
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
@ -107,7 +107,7 @@ Future<Widget> initialize() async {
|
||||
);
|
||||
}
|
||||
|
||||
void _initLogging() {
|
||||
void _initLogging(List<String> argv) {
|
||||
Logger.root.onRecord.listen((record) {
|
||||
stderr.writeln('[${record.loggerName}] ${record.level}: ${record.message}');
|
||||
if (record.error != null) {
|
||||
@ -115,11 +115,10 @@ void _initLogging() {
|
||||
}
|
||||
});
|
||||
|
||||
final arguments = Platform.executableArguments;
|
||||
final logLevelIndex = arguments.indexOf('--log-level');
|
||||
final logLevelIndex = argv.indexOf('--log-level');
|
||||
if (logLevelIndex != -1) {
|
||||
try {
|
||||
final levelName = arguments[logLevelIndex + 1];
|
||||
final levelName = argv[logLevelIndex + 1];
|
||||
Level level = Level.LEVELS
|
||||
.firstWhere((level) => level.name == levelName.toUpperCase());
|
||||
Logger.root.level = level;
|
||||
|
@ -13,13 +13,13 @@ import 'error_page.dart';
|
||||
|
||||
final _log = Logger('main');
|
||||
|
||||
void main() async {
|
||||
void main(List<String> argv) async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
try {
|
||||
final Widget initializedApp;
|
||||
if (isDesktop) {
|
||||
initializedApp = await desktop.initialize();
|
||||
initializedApp = await desktop.initialize(argv);
|
||||
} else if (isAndroid) {
|
||||
initializedApp = await android.initialize();
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user