app_logger 0.0.6

SDKflutter
Platformandroidioswindowslinuxmacos

Log all Http request and Navigation.

alt_text

app_logger

A package for log exception, http request and navigation

Usage

add this line to pubspec.yaml


dependencies:
  app_logger: ^0.0.6

import package


import 'package:app_logger/app_logger.dart';

We init the package

void main() {
  AppLogger.init(
    'https://example.com',
    true,
    true,
        () => runApp(const MyApp()),
  );
}

Then to change the configuration of the package

AppLogger.instance.configuration.setUser(
  AppLoggerUser(id: '123123213123', username: 'Mustafa'),
);

Navigation Logger

MaterialApp(
  navigatorObservers: [NavigationLogger.instance],
  onGenerateRoute: MyRouteFactory().main.onGenerateRoute,
);

Api Logger

Future<void> getRequest() async {
  final uri = Uri.https('jsonplaceholder.typicode.com', 'todos/1');
  final res = await http.get(
    uri,
    headers: {"content-type": "application/json"},
  );
  HttpLogger.instance.log(
    url: uri.toString(),
    statusCode: res.statusCode,
    header: {},
    requestBody: {},
    responseBody: res.body,
  );
}

Parameters

ParameterDescriptions
baseUrlBaseUrl
headersHeader
callBackFunIf is not null, the function is called when a log is taken. If it is null, a post request is sent to the endpoint given in baseUrl.
onErrorRuns when an error occurs
configuration
httpLogHttp log status
navigationLogNavigation log status
killAppOnErrorShould the application close when an error occurs?
killAppOnErrorCausedByFlutterShould Flutter close the application when an error occurs?
useruser