magillus / flutter-fimber Goto Github PK
View Code? Open in Web Editor NEWFimber is Flutter logger inspired by Timber (logger API for Android)
Fimber is Flutter logger inspired by Timber (logger API for Android)
I can't find the methodFimber.addTree,please update docs.
void main() {
Fimber.addTree(DebugTree());
// app code here ...
}
Allow to call Fimber.mute(["D","I"])
on all trees
levelToke. it should be levelToken
, right?
I just upgraded to Flutter 2.0.1/dart 2.12.0
I updated to flutter_fimber: ^0.6.1
I have lost all logging and I get the following error message repeatedly running on an Android device or an Android emulator.
E/flutter ( 9268): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: MissingPluginException(No implementation found for method log on channel flutter_fimber) E/flutter ( 9268): #0 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:156:7) E/flutter ( 9268): <asynchronous suspension> E/flutter ( 9268):
I did flutter clean / flutter pub upgrade.
I tried pouring over the documentation for flutter 2 to see if I need to change my project in some way. I did not find any guides on changes that I need to make.
Thanks in advance for any help you can give on this issue.
As I see in source, you are using print
, maybe worth it to use debugPrint
(from Flutter) to avoid problems on Android?
https://flutter.io/docs/testing/debugging#print-and-debugprint-with-flutter-logs
Error code:
.../Pub/Cache/hosted/pub.dartlang.org/flutter_fimber-0.6.0/lib/flutter_fimber.dart:1:8: Error: Error when reading '.../Pub/Cache/hosted/pub.dartlang.org/fimber-0.6.1/lib/colorize.dart': The system cannot find the file specified.
import 'package:fimber/colorize.dart';
^
FAILURE: Build failed with an exception.
Add optional parameter to mute
and unmute
methods that would say which log Tree the action should be limited to.
Add optional Tree's id as String to better identify it.
Thanks to Saïd for suggestion.
Log tag fetched from log statement in constructor does show only new
.
example:
12-03 18:12:36.125 3225-3225/cc.example D/new: Activating dashboard for user testUser
Update split by (' ') so if stacktrace line starts with new
it would add class name.
Looks like fimber and fimber-io were updated to 0.4.0, but flutter_fimber stays on "0.3.2". Therefore I can't integrate both fimber-io and flutter-fimber in my project. Thanks.
I'm using Fimber for logging in an app that interacts with a REST API. To allow easy troubleshooting on the client side, I would like to show recent logging messages on the frontend (e.g. in a ListView
).
Would it possible to retrieve messages from a static method in the Fimber library? Perhaps the method could return something along the lines of a List<FimberLogObject>
.
Hi guys,
I'm using Fimber for a project, and wanted to have colored output. I used the code below. However, I still get white-only output. I'm using iTerm2 on MacOS Catelina (10.15.3).
final tree = DebugTree(useColors: true);
Fimber.plantTree(tree);
Any idea?
Hi!
Thank you for this library. Sometimes you need to send logs to someone with a file during development. Now this is hard to do. Could you add a method that can return log files list?
Thanks
Also check directories and subdirectories createions.
Add those to example
Please can you add a colorizing tree?
Due to my previous Kotlin/Java experience I tended to use different codestyles then expected from Dart language.
A simple LogTree
implementation that sends logs over a network connection (using Netcat) to a terminal window.
Usecase: view logs for an app that is being cold started: i.e. on push notification or app tray/launcher icon press
/// Terminal
/// nc -kvl 5601 | grep TheClassName
class NetworkLoggingTree extends CustomFormatTree {
NetworkLoggingTree._(this._socket)
: super(
useColors: true,
logFormat: '${CustomFormatTree.levelToken} ${CustomFormatTree.tagToken}: ${CustomFormatTree.messageToken}',
);
static Future<NetworkLogging> create(String server, int port) async {
final socket = await Socket.connect(
server,
port,
timeout: const Duration(seconds: 10),
);
return NetworkLogging._(socket);
}
final Socket _socket;
@override
void printLine(String line, {String level}) {
super.printLine(line, level: level);
_socket.writeln(line);
}
}
Plant your tree:
/// enter your computer's IP address, and the port that comms will be using
Fimber.plantTree(
await NetworkLoggingTree.create('192.168.86.28', 5601),
);
Usage:
First start a terminal window and enter the net connection command. Use grep if you want to watch logs for a particular class
Then launch your app.
nc -kvl 5601 | grep TheClassName
This is a rough, the NetworkLoggingTree
currently extends CustomFormatTree
and has the advantage of showing logs in both Terminal and in your regular IDE Output window. I have not managed to get colours to work yet
Further options for Netcat here: https://www.computerhope.com/unix/nc.htm
try catch
block provides stacktrace, use that with ex
to pass to loggin.
This will give more precise location of logging.
Does this work on all versions of swift? We had an error about swift version..
I'd like to disable log when I use release mode
How to disable or disappear log my case?
Am I using it correctly?
if (kReleaseMode) {
Fimber.d('release mode');
} else {
Fimber.plantTree(DebugTree());
Fimber.d('debug mode');
}
TimedRollingFileTree(
{this.timeSpan = TimedRollingFileTree.dailyTime,
logFormat = CustomFormatTree.defaultFormat,
this.filenamePrefix = "log_",
this.filenamePostfix = ".txt",
logLevels = CustomFormatTree.defaultLevels}) {
fileNameFormatter = LogFileNameFormatter.full(
prefix: filenamePrefix, postfix: filenamePostfix);
rollToNextFile();
}
should like this
TimedRollingFileTree(
{this.timeSpan = TimedRollingFileTree.dailyTime,
logFormat = CustomFormatTree.defaultFormat,
this.filenamePrefix = "log_",
this.filenamePostfix = ".txt",
logLevels = CustomFormatTree.defaultLevels}) :super(logLevels: logLevels, logFormat: logFormat){
fileNameFormatter = LogFileNameFormatter.full(
prefix: filenamePrefix, postfix: filenamePostfix);
rollToNextFile();
}
to call super(logLevels: logLevels, logFormat: logFormat)
hi, and thanks for a great library!
I just ran into what might be a little issue here: I couldn't get the Verbose level to show, so running the debugger, I found out I had two "V" String objects into the Fimber._muteLevels list... I probably did miss something while handling the list, but it might be an idea anyway to protect the list agains duplicates (check if not already present when adding for ex).
Best regards, and thanks a lot again, keep up good work!
I also tried the TimedRollingFileTree
but unfortunately it is constantly rolling (with every log call) because in shouldRollNextFile()
var now = DateTime.now();
if (fileNameFormatter.format(now) !=
fileNameFormatter.format(_currentFileDate)) {
_currentFileDate = now;
return true;
}
the fileNameFormatter.format calls are always not equal and therefore true is always returned.
I am trying to initialize it the following way:
TimedRollingFileTree(
timeSpan: TimedRollingFileTree.weeklyTime,
filenamePrefix: '${logFilePrefix}log',
logLevels: CustomFormatTree.defaultLevels);
This may be more of a question than an issue with Fimber, but I'm not sure.
I'm using Android Studio 4.1.2
I'm seeing the output twice in the 'Run' console of Android Studio. Here is a simple example...
D/BladePortsHolder._refresh(23318): refreshing
I/flutter (23318): 0:07:30.746915 D BladePortsHolder._refresh: refreshing
The first output has the function name and my output.
The second output has the same thing with flutter, a numeric id and the time.
Perhaps I just need to change a setting? I would like to see only one output. Doubling the output
I'm using the current Beta channel of flutter but I don't think that matters. Channel beta, 1.26.0-17.3.pre. Dart version 2.12.0 (build 2.12.0-259.8.beta).
flutter_fimber: ^0.4.4
Here is my main function
`void main() async {
Fimber.plantTree(FimberTree(useColors: true));
Fimber.plantTree(DebugTree.elapsed());
await HiveHelper.init();
AppState.instance = AppState();
await AppState.instance.init();
runApp(IntellaViewMobileApp());
}`
Originally reported by @nodinosaur
https://github.com/magillus/flutter-fimber/blob/master/fimber/lib/fimber_base.dart#L439
doesn't pass level to get correct coloring on printLine
There is some incompatibility with switf/kotlin and also on Android the size of APK with included kotlin lib is not necessary, not always requirement.
This is my current implementation of DebugTree
in Timber.
class CustomDebugTree : Timber.DebugTree() {
override fun createStackElementTag(element: StackTraceElement): String? {
return "(${element.fileName}:${element.lineNumber})#${element.methodName}"
}
}
I was trying to achieve the same in Fimber, but I don't see any formatting options to get the line number or file name. I tried to create a custom Tree
as in Timber but the stack trace that is passed in the log
function is null. Looks like we need to supply the stack trace as well when calling Fimber's log function. Can we do something about this, maybe using a default argument StackTrace.current
in the function argument.
I try to use Fimber.d()
in an Isolates and notice it doesn't print any log.
Version: fimber: ^0.3.2
.
As I now, Fimber isn't Dart plugin, so do you know why it doesn't work in Isolates?
Recently Ive noticed that I
m not able to see any activity from my logging service (FimberLog for each class). I`ve checked the Logcat in Android Studio that filters are set correctly (checked without any filters), and I still could not find any logs made from FimberLog..
This is how initialize the logger:
FimberLog getLogger(dynamic obj) {
if (obj == null) {
return null;
}
final Type t = obj.runtimeType;
return FimberLog(t.toString());
}
[√] Flutter (Channel stable, v1.9.1+hotfix.4, on Microsoft Windows [Version 10.0.18362.418], locale en-GB)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 3.5)
[√] Connected device (1 available)fimber: ^0.3.2
Hi,
After issuing a call on two different levels after each other, only the last log gets outputted to the file
Fimber.plantTree(TimedRollingFileTree(filenamePrefix: "/data/data/be.ifm.buildingviewerflutter/log_"));
Fimber.e("Crashing app", stacktrace: StackTrace.fromString("sdfsdfs"), ex: String);
Fimber.e("Crashing app", stacktrace: StackTrace.fromString("sdfsdfs"), ex: String);
Fimber.i("Running app");
File output:
2019-03-09T14:13:51.887683 I main: Running app
Hello,
Do you plan to migrate to flutter_embedding v2?
The plugin `flutter_fimber` is built using an older version of the Android plugin API which assumes that
it's running in a full-Flutter environment. It may have undefined behaviors when Flutter is integrated
into an existing app as a module.
The plugin can be updated to the v2 Android Plugin APIs by following
https://flutter.dev/go/android-plugin-migration.
okay my head is still asleep...must be turkey I ate?
If I extend the fimber class than I should be able to enable some default app logs with colorize color coding so I do not have to manually add the colorize wrap to every log statement I write.
But its a temporary hack.
Is there a better way to do it?
See: https://flutter.dev/docs/testing/code-debugging#logging
use:
import 'dart:developer' as developer;
developer.log(
'log me',
name: 'my.app.category',
error: jsonEncode(myCustomObject),
);
Do you plan to support maxHistoryFiles in TimedRollingFileTree class?
Currently there is only a declaration of maxHistoryFiles variable, but it is not used.
I assume Fimber should should delete log files if there is more than stored files.
I am using SizeRollingFileTree and I want to retrieve the current log file from the filesystem so I can display it etc.
How can I achieve this? Is there a function that gives me the current log or do I have to search the filesystem by myself?
I/flutter (29013): �[32m2020-01-30T12:09:16.341436 D AdsUtils._handleEvent: New Banner Ad loaded!�[0m
You can see them in the beginning and in the end
When the log is big then it is cut from the terminal and you can't see the full output.
debugPrint(someSuperLongString, wrapWidth: 1024);
One one to overcome this is by using another function by logging
flutter/flutter#22665 (comment).
Is there any way to overcome this?
fimber
packed dart only packagefimber
to use native loggingDiscover how to do this in both flutter/dartvm environments
It looks like the class/method names that I get on Android with Fimber
does not work the same way on web. I'd like to be able to log the calling class and method name on web, too.
And, can that file be easily visible using Windows?
After upgrading my app to Flutter 2.0.2 (without nullSafety) i get the following error while building for android (ios works fine):
Launching lib/main.dart on Android SDK built for x86 in debug mode...
Running Gradle task 'assembleDebug'...
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':app:processDebugResources'.
Android resource linking failed
/Users/FOO/projects/BAM/energielabel_app/build/app/intermediates/merged_manifests/debug/AndroidManifest.xml:17: AAPT: error: unexpected element found in .
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 10s
The build failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetifier to solve the incompatibility.
Building plugin flutter_fimber...
Running Gradle task 'assembleAarRelease'...
e: /Users/FOO/.pub-cache/hosted/pub.dartlang.org/flutter_fimber-0.6.2/android/src/main/kotlin/com/magillus/flutterfimber/FlutterFimberPlugin.kt: (3, 28): Unresolved reference: NonNull
e: /Users/FOO/.pub-cache/hosted/pub.dartlang.org/flutter_fimber-0.6.2/android/src/main/kotlin/com/magillus/flutterfimber/FlutterFimberPlugin.kt: (20, 38): Unresolved reference: NonNull
e: /Users/FOO/.pub-cache/hosted/pub.dartlang.org/flutter_fimber-0.6.2/android/src/main/kotlin/com/magillus/flutterfimber/FlutterFimberPlugin.kt: (25, 32): Unresolved reference: NonNull
e: /Users/FOO/.pub-cache/hosted/pub.dartlang.org/flutter_fimber-0.6.2/android/src/main/kotlin/com/magillus/flutterfimber/FlutterFimberPlugin.kt: (25, 59): Unresolved reference: NonNull
e: /Users/FOO/.pub-cache/hosted/pub.dartlang.org/flutter_fimber-0.6.2/android/src/main/kotlin/com/magillus/flutterfimber/FlutterFimberPlugin.kt: (51, 40): Unresolved reference: NonNull
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':compileReleaseKotlin'.
Compilation error. See log for more details
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 5s
Exception: The plugin flutter_fimber could not be built due to the issue above.
Add method to remove single tree:
Hi
Intellij advise me to add two possible imports when using Fimber.
:
// 1.
import 'package:fimber/fimber_base.dart';
// 2.
import 'package:fimber/fimber.dart';
Which one should we choose? and why?
Hi! I'm trying to use SizeRollingFileTree
in my app
void main() {
Fimber.plantTree(DebugTree());
Fimber.plantTree(SizeRollingFileTree(DataSize(megabytes: 1)) );
Fimber.d("starting app");
pubspec.yaml:
dependencies:
fimber_io: ^0.4.4
fimber: ^0.4.4
and I've got this error on Android 10 device, storage permission granted
E/flutter (19744): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: FileSystemException: Directory listing failed, path = 'log_/' (OS Error: No such file or directory, errno = 2)
E/flutter (19744): #0 _Directory._fillWithDirectoryListing (dart:io-patch/directory_patch.dart:37:68)
E/flutter (19744): #1 _Directory.listSync (dart:io/directory_impl.dart:243:5)
E/flutter (19744): #2 SizeRollingFileTree.detectFileIndex (package:fimber_io/src/file_log.dart:149:10)
E/flutter (19744): #3 new SizeRollingFileTree (package:fimber_io/src/file_log.dart:137:5)
E/flutter (19744): #4 main (package:myapp/main.dart:15:20)
E/flutter (19744): #5 _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:233:25)
E/flutter (19744): #6 _rootRun (dart:async/zone.dart:1190:13)
E/flutter (19744): #7 _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (19744): #8 _runZoned (dart:async/zone.dart:1630:10)
E/flutter (19744): #9 runZonedGuarded (dart:async/zone.dart:1618:12)
E/flutter (19744): #10 _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:225:5)
E/flutter (19744): #11 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
E/flutter (19744): #12 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
Shouldn't the directory be created by fimber?
Hello! Thanks for this amazing library!
This helps me a lot!
Is there any way to print the logs without timestamp?
and it seems I need to set my own settings to android studio to colorize the logs, but how?
Thank you again
instructions in readme.me refer to addtree, planttree is correct?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.