Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions fimber_io/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ build/

# Directory created by dartdoc
doc/api/

# file generated by the example
test.log
# folder generated by the tests
test_logs/
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.magillus.flutter_fimber

import androidx.annotation.NonNull

import android.util.Log
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
Expand All @@ -16,20 +15,38 @@ class FlutterFimberPlugin: FlutterPlugin, MethodCallHandler {
/// when the Flutter Engine is detached from the Activity
private lateinit var channel : MethodChannel

override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "flutter_fimber")
channel.setMethodCallHandler(this)
}

override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
if (call.method == "getPlatformVersion") {
result.success("Android ${android.os.Build.VERSION.RELEASE}")
} else {
result.notImplemented()
override fun onMethodCall(call: MethodCall, result: Result) {
when (call.method) {
"getPlatformVersion" -> result.success("Android ${android.os.Build.VERSION.RELEASE}")
"log" -> log(call, result)
else -> result.notImplemented()
}
}

override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) {
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
channel.setMethodCallHandler(null)
}

private fun log(call: MethodCall, result: Result) {
val tag = call.argument<String?>("tag") ?: "flutter"
val message = call.argument<String?>("message") ?: ""
val level = call.argument<String?>("level") ?: "V"
val throwable = call.argument<String?>("ex")?.let { Throwable(it) }

when (level) {
"V" -> Log.v(tag, message, throwable)
"D" -> Log.d(tag, message, throwable)
"I" -> Log.i(tag, message, throwable)
"W" -> Log.w(tag, message, throwable)
"E" -> Log.e(tag, message, throwable)
"WTF" -> Log.wtf(tag, message, throwable)
else -> Log.d(tag, message, throwable)
}
result.success(null)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:exported="true"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
Expand Down
2 changes: 1 addition & 1 deletion flutter_fimber/example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}

task clean(type: Delete) {
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion flutter_fimber/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class _MyAppState extends State<MyApp> {
onPressed: () {
try {
throw AssertionError();
} on Exception catch (e, s) {
} on AssertionError catch (e, s) {
Fimber.w("Warning message test ${DateTime.now()}",
ex: e, stacktrace: s);
}
Expand Down