2022-04-13 16:26:32 +03:00
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:logging/logging.dart';
|
|
|
|
|
2022-05-06 18:45:34 +03:00
|
|
|
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'];
|
2022-05-06 18:45:34 +03:00
|
|
|
|
|
|
|
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;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|