mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-25 23:14:18 +03:00
Use custom flutter LogLevels from Android
This commit is contained in:
parent
ce78d7a25a
commit
8328f76b46
@ -62,7 +62,8 @@ class MainActivity : FlutterFragmentActivity() {
|
||||
}
|
||||
|
||||
override fun logDebug(message: String) {
|
||||
FlutterLog.d(message)
|
||||
// redirect yubikit debug logs to flutter traffic
|
||||
FlutterLog.t(message)
|
||||
}
|
||||
|
||||
override fun logError(message: String, throwable: Throwable) {
|
||||
|
@ -1,20 +1,12 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import '../app/logging.dart';
|
||||
|
||||
class AndroidLogger {
|
||||
final _androidLogger = Logger('android.redirect');
|
||||
final MethodChannel _channel = const MethodChannel('android.log.redirect');
|
||||
|
||||
final levelMap = <String, Level>{
|
||||
't': Level.FINE,
|
||||
'd': Level.CONFIG,
|
||||
'i': Level.INFO,
|
||||
'w': Level.WARNING,
|
||||
'e': Level.SEVERE,
|
||||
'wtf': Level.SHOUT,
|
||||
'v': Level.ALL,
|
||||
};
|
||||
|
||||
static AndroidLogger? instance;
|
||||
static void initialize() {
|
||||
instance = AndroidLogger();
|
||||
@ -25,7 +17,28 @@ class AndroidLogger {
|
||||
var level = call.arguments['level'];
|
||||
var message = call.arguments['message'];
|
||||
var error = call.arguments['error'];
|
||||
_androidLogger.log(levelMap[level] ?? Level.INFO, message, 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;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user