Created
March 7, 2021 21:03
-
-
Save fredgrott/0e62682f0ce811fe6a1f1d05f64ae3c7 to your computer and use it in GitHub Desktop.
showing how to use fimber plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:fimber/fimber.dart'; | |
import 'package:fimber_io/fimber_io.dart'; | |
import 'package:flutter/widgets.dart'; | |
import 'package:path_provider/path_provider.dart'; | |
// setting tag for the whole app | |
FimberLog logger = FimberLog("flutter_log_fimber"); | |
Fimber plantMeDebug() { | |
Fimber.plantTree(DebugTree.elapsed(useColors: true)); | |
return Fimber(); | |
} | |
Future<String> getLocalPath() async { | |
WidgetsFlutterBinding.ensureInitialized(); | |
final directory = await getApplicationDocumentsDirectory(); | |
return directory.path; | |
} | |
Future<Fimber> plantFileTree() async { | |
final String tempPath = await getLocalPath(); | |
// ignore: await_only_futures | |
await Fimber.plantTree(FimberFileTree( | |
"${tempPath}my-Log-File.txt", | |
logFormat: | |
"${CustomFormatTree.timeElapsedToken} ${CustomFormatTree.messageToken} ${CustomFormatTree.timeStampToken}", | |
)); | |
return Fimber(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment