In-app debug console and logger for Flutter to monitor the app on-air.
- π Graphical Console: a beautiful graphical console for debugging.
- π Password Protection: add password protection to graphical console.
- π‘ Network Requests: see network requests, responses, status code and size.
- π Database Writes: see database write transactions and their content.
- π€ Share Logs: share all kinds of logs with platform share window.
Dashboard | Request Details | Password Protection |
---|---|---|
Hi, I'm Kamran. I've been using this package for a while in the projects I work on. It's a simple and great tool and if you ever need help with it create an issue.
To use this package, add logarte
as a dependency in your pubspec.yaml
file:
dependencies:
logarte: -latest_version-
Then, run flutter pub get
in your terminal to install the package.
You'll need a Logarte
instance throughout the app. I, personally, prefer to store a global instance of Logarte
in a separate file.
final Logarte logarte = Logarte(
// Password for protecting the console
password: '1234',
// Whether to ignore the password
ignorePassword: !kReleaseMode,
// Sharing the network request log with system share window
onShare: (String message) {
Share.share(message);
},
// Action to be performed when the rocket button is long pressed
onRocketLongPressed: (BuildContext context) {
// Example: toggle theme mode
print('Rocket long pressed');
},
// Action to be performed when the rocket button is double tapped
onRocketDoubleTapped: (BuildContext context) {
// Example: switch between languages
print('Rocket double tapped');
},
);
The Logarte
console can be opened by two methods: clikcing the entry rocket button or using LogarteMagicalTap
which opens the console when tapped 10 times.
It's a floating button that can be used to open the console from anywhere in the app. You simply attach it to the UI and it will be visible on top of everything. Add a boolean to the attach
method to make it visible only in debug mode, or in any other condition.
@override
void initState() {
super.initState();
logarte.attach(
context: context,
visible: !kReleaseMode,
);
}
LogarteMagicalTap
is a widget that attaches the entry rocket button to the UI when tapped 10 times. Wrap any non-tappable widget, and keep it secret.
LogarteMagicalTap(
logarte: logarte,
child: Text(
'LibroKit v2.2',
),
)
You can track network requests by either using LogarteDioInterceptor
for Dio
or the custom method for other clients.
_dio = Dio()
..interceptors.add(
LogarteDioInterceptor(logarte),
);
That's it? Yes, that's it. Now, all the network requests will be logged in both the debug and the graphical console.
import 'package:http/http.dart' as http;
final body = {
'name': 'Kamran',
'age': 22,
};
final headers = {
'Content-Type': 'application/json',
};
final endpoint = 'https://api.example.com';
final response = await http.post(
Uri.parse(endpoint),
headers: headers,
body: jsonEncode(body),
);
logarte.network(
request: NetworkRequestLogarteEntry(
method: 'POST',
url: endpoint,
headers: headers,
body: body,
),
response: NetworkResponseLogarteEntry(
statusCode: response.statusCode,
headers: response.headers,
body: response.body,
),
);
You can log messages to the console using the info
method of the Logarte
instance and then see them in the graphical console.
logarte.info('This is an info message');
I'll add more methods for different log types in the future.
To track the navigator routes, you can add LogarteNavigatorObserver
to the MaterialApp
's navigatorObservers
list.
MaterialApp(
navigatorObservers: [
LogarteNavigatorObserver(logarte),
],
)
To track database writes, you can use the database
method of the Logarte
instance.
logarte.database(
target: 'language',
value: 'en',
source: 'SharedPreferences',
);
For a more detailed example, check the example directory in this repository.
This package is open-source and released under the MIT License.