-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Since the plugin is not working and the dev does not have time to fix it #135 (comment), i quickly hacked a replacement solution. Maybe it helps someone.
pubspec.yaml
...
logging: ^1.2.0
...
main.dart
//removing fimber because it is a broken plugin
Future<void> _setupFimberLog() async {
// Fimber.clearAll();
// Fimber.plantTree(FimberTree());
var directory = await getApplicationDocumentsDirectory();
final fileName = "fimber_log.txt";
final filePath = "${directory.path}/$fileName";
//delete file if > than 1M
var file = File(filePath);
if (file.existsSync() && file.lengthSync() > 1 * 1024 * 1024) {
print("deleting log file $filePath with length ${file.lengthSync()}");
file.deleteSync();
}
// Fimber.plantTree(FimberFileTree(filePath,
// logFormat:
// "${CustomFormatTree.timeStampToken}\t${CustomFormatTree.messageToken}\t${CustomFormatTree.timeElapsedToken}"));
Logger.root.level = Level.ALL; // defaults to Level.INFO
Logger.root.onRecord.listen((record) {
String message = '${record.message}';
if (record.level.value >= Level.WARNING.value)
message = '${record.level.name}: ${record.time}: ${record.message}';
print(message);
String content = '${record.level.name}: ${record.time}: ${record.message}';
file.writeAsString(content, mode: FileMode.append, flush: true);
});
}
debug.dart
class Debug {
static d(String string) {
//Fimber.d(string);
Logger("debug").fine(string);
}
static e(String string) {
//Fimber.e(string);
Logger("debug").severe(string);
}
static ex(String string, dynamic e, StackTrace s) {
Logger("debug").severe(string, e, s);
}
}
Thank you for the developer for giving us the Fimber plugin, hope it will be updated sometime.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels