Coder Social home page Coder Social logo

whitecloud-sas / logarte Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kamranbekirovyz/logarte

0.0 0.0 0.0 1.51 MB

๐Ÿชต In-app debug console and logger for Flutter

Home Page: https://pub.dev/packages/logarte

License: MIT License

Ruby 2.21% C++ 18.42% C 1.12% Objective-C 0.03% Kotlin 0.10% Dart 60.33% Swift 1.54% HTML 1.45% CMake 14.80%

logarte's Introduction

logarte

In-app debug console and logger for Flutter to monitor the app on-air.

๐Ÿ“ฆ Features

  • ๐Ÿš€ 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.

๐Ÿ“ฑ Screenshots

Dashboard Request Details Password Protection

๐Ÿ‘‹๐Ÿป Words from the author

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, join my Telegram channel or create an issue.

๐Ÿชš Installation

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.

๐Ÿš€ Usage

Initialize

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');
    },
);

Open the console

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.

Rocket Entry Button

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,
    visilble: !kReleaseMode,
  );
}

LogarteMagicalTap

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',
  ),
)

Track Network Requests

You can track network requests by either using LogarteDioInterceptor for Dio or the custom method for other clients.

Dio

_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.

Other Clients

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,
  ),
);

Log messages

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.

Track Navigator Routes

To track the navigator routes, you can add LogarteNavigatorObserver to the MaterialApp's navigatorObservers list.

MaterialApp(
  navigatorObservers: [
    LogarteNavigatorObserver(logarte),
  ],
)

Track Database Writes

To track database writes, you can use the database method of the Logarte instance.

logarte.database(
  target: 'language',
  value: 'en',
  source: 'SharedPreferences',
);

๐Ÿ•น๏ธ Example

For a more detailed example, check the example directory in this repository.

๐Ÿ“„ License

This package is open-source and released under the MIT License.

logarte's People

Contributors

kamranbekirovyz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.