logs
logs copied to clipboard
Status of this package ?
Hey there! I've found this package from https://flutter.github.io/devtools/logging.html for logging http calls. I am wondering about the status of this package. Is it still the recommended way to log http calls ?
This package was essentially a proof of concept but I know some folks continue to find it useful... I know @devoncarew and @jacob314 have talked about a more robust solution but I'm not sure if there is any update... Maybe they can chime in.
Thanks for the interest!
@pq I read through some your proposals and stumbled into this repo.
I like the idea of selectively enabling/disabling filters for logging. Right now I want to only enable network activity for GraphQL requests and a few performance items to track down some bugs. If I was able to check off the right log channels to subscribe to, it would make my life a lot easier.
Log-level seems to be the industry standard but I feel that it is too all-or-nothing. You either get a firehose of DEBUG-level logs you have to sort through or nothing at all. Or you have to really go out of your way to hunt down where something is being logged and enable/disable that.
Hi @venkatd! Thanks for the interest and you're spot on with your motivations for this package. A bit of work has been done on logging over in the https://github.com/flutter/devtools project since but I'm not up on the latest.
Maybe @jacob314, @kenzieschmoll or @terrylucas can chime in?
(Also fyi @devoncarew.)
We've recently added a network page to DevTools to help debug network traffic issues. It is still early but it is where it would make sense to add any additional features to productively filter network traffic. https://flutter.dev/docs/development/tools/devtools/network
For cases where you are wanting to track down performance bugs, you can trace events and see them visually in the timeline page nicely integrated with other timeline debugging features. For example, if you trace the events correctly, it is one click to go from the time range from the events to a wide range of cpu profiling tools analyzing what happened during that time range. https://flutter.dev/docs/development/tools/devtools/timeline
Thanks! Those should help a lot for this use case.
I do wish I had the ability to enable/disable logs on a more granular level for other purposes. I'll write up a more detailed use case when it comes up.
Here's a more specific use case. We have a library for accessing our backend graphql api. In some cases I have debug statements as follows:
class TurtleGraphQLClient implements GraphQLClient<RootQueryType, RootMutationType, RootSubscriptionType> {
/// ...
@override
Future<RootQueryType> query(
String graphql, {
Map<String, dynamic> variables,
Duration timeout = const Duration(seconds: 10),
}) async {
// final sw = Stopwatch()..start();
final json = await graphQLClient.query(
graphql,
variables: variables,
timeout: timeout,
);
// sw.stop();
// print(gqlOpHeaders(graphql, variables) + ' [${sw.elapsedMilliseconds}ms]');
return RootQueryType.fromJson(json);
}
/// ...
}
I could browse network requests, but most of the logging I have is optimized for our situation. In this case, only the graphql operation, the variables, and how long each request took are printed out. The network tab would show a lot more information.
I would like to selectively toggle this log when I want to check if requests are being called at the right time.
To do this, I find myself commenting/uncommenting log code. Having to choose between log levels is either (1) show all logs with that level or (2) don't show any logs at all for that level. (There may be a practice which I'm unaware of, but this the path of least-resistance for me.)
Here are a few more use cases:
- We have an internal routing library (similar to Fluro) and sometimes it helps to enable logs to see how the current url was matched. Turning on debug level logging would give us a firehose of logs
- We have a websocket class that deals with reconnecting automatically, sending heartbeats, etc. Would like to sometimes turn just this and a few other logs on when dealing with connectivity issues on some in-the-wild builds.
As I understand, this library would allow me to send messages to channels and I could enable/disable the channels I need for any use case. I think this capability would get me 90% of the way there and include other developers on our team to add helpful logging to our internal packages.
@venkatd - you might consider filling this as a feature request against devtools (https://github.com/flutter/devtools); more sophisticated display and filtering of logging there would be great.