yubioath-flutter/lib/android/logger.dart

46 lines
1.1 KiB
Dart
Raw Normal View History

2022-04-13 16:26:32 +03:00
import 'package:flutter/services.dart';
import 'package:logging/logging.dart';
import '../app/logging.dart';
2022-04-13 16:26:32 +03:00
class AndroidLogger {
final _androidLogger = Logger('android.redirect');
final MethodChannel _channel = const MethodChannel('android.log.redirect');
static AndroidLogger? instance;
static void initialize() {
instance = AndroidLogger();
}
AndroidLogger() {
_channel.setMethodCallHandler((call) async {
var level = call.arguments['level'];
var message = call.arguments['message'];
var error = call.arguments['error'];
switch (level) {
case 't':
case 'v':
_androidLogger.traffic(message, error);
break;
case 'd':
_androidLogger.debug(message, error);
break;
case 'w':
_androidLogger.warning(message, error);
break;
case 'e':
case 'wtf':
_androidLogger.error(message, error);
break;
case 'i':
default:
_androidLogger.info(message, error);
break;
}
2022-04-13 16:26:32 +03:00
return 0;
});
}
}