emodebug 0.4.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 72

Emodebug #

pub package doc

Emoji based semantic debuging:

  • Debug the state and execution flow of your program using familiar idioms
  • Scoped debuging: activate debug locally
  • Easy implementation of custom debug methods: extend the EmoDebug class to create your own methods

Looking at the console you get an intuitive global view on the execution flow:

Screenshot

Note: this is not for error management, you can use Err and ErrRouter to manage the errors.

Example #

   import 'package:emodebug/emodebug.dart';

   const EmoDebug debug = EmoDebug();

   debug.state("A state operation");
   debug.save("Saving something");
   debug.delete("Deleting something");
   debug.update("Updating something");
   debug.ok("Everything is ok");
   // or from an emoji using any object or a string
   debug.emo("📢", obj);

Available methods: check the api documentation

Parameters #

The methods accept any object as parameter (dynamic)

An optional domain positional parameter is available for a more precise message:

   final data = {"foo": "bar"};
   debug.data(data, "some data");
   // output:
   // 💼 Some data: {foo: bar}

Scoped debuging #

The recommended way is to use local EmoDebug instances to be able to enable and disable debug messages for a defined portion of code. Use the level attribute to prefix the messages:

   const EmoDebug _ = EmoDebug(level: "http service");
   // the messages will be prefixed by [http service] :
   _.notFound(path, "page not found");
   // output:
   // 🚫 [http service] Page not found: /some_page.html

Deactivation #

It is possible to deactivate the printing of the messages for an instance:

   // on top of a file
   const EmoDebug debug = EmoDebug(deactivatePrint: true);

Implement custom debug methods #

   const CustomEmoDebug debug = CustomEmoDebug();

   class CustomEmoDebug extends EmoDebug {
     const CustomEmoDebug();
   
     void crash(dynamic obj, [String domain]) => emo("💥", obj, domain);
   
     void recovery(dynamic obj, [String domain]) => emo("👍", obj, domain);
   }

   // in the code
   debug.crash("A crash occured!!!");
   debug.recovery("Recovery successful");

Changelog #

0.4.0 #

Add some emo methods

0.3.0 #

  • Add the level parameter
  • Add the deactivate parameter
  • Add some emo methods

0.2.0 #

  • Add some methods
  • Add a deactivated mode

0.1.0 #

Initial

example/lib/main.dart

import 'package:emodebug/emodebug.dart';

/// The normal [EmoDebug] class initialization
//const EmoDebug debug = EmoDebug();

/// The custom implementation
const CustomEmoDebug debug = CustomEmoDebug();

/// A class that extends [EmoDebug] with custom methods
class CustomEmoDebug extends EmoDebug {
  /// The base constructor
  const CustomEmoDebug();

  /// The crash method to indicate a program failure
  void crash(dynamic obj, [String domain]) => emo("💥", obj, domain);

  /// The recovery method to indicate a program recovery
  void recovery(dynamic obj, [String domain]) => emo("👍", obj, domain);
}

void main() {
  _printLines(1);
  debug.init("Initializing");
  _printLines(3);
  debug.ok("Everything is ok");
  _printLines(2);
  debug.state("A state operation");
  _printLines(1);
  debug.save("Saving something");
  _printLines(2);
  debug.delete("Deleting something");
  _printLines(3);
  debug.update("Updating something");
  _printLines(2);
  _printLines(1);
  final data = {"foo": "bar"};
  debug.data(data, "some data");
  _printLines(2);
  debug.crash("A crash occured!!!");
  _printLines(4);
  debug.recovery("Recovery successful");
  _printLines(3);
  debug.emo("🏁", "Finish");
}

var _i = 1;

void _printLines(int n) {
  var i = 0;
  while (i < n) {
    print("[$_i] Normal debug message flow message");
    ++i;
    ++_i;
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  emodebug: ^0.4.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:emodebug/emodebug.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
45
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
72
Learn more about scoring.

We analyzed this package on Jul 10, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
extra_pedantic ^1.1.1+3 1.2.0
pedantic ^1.8.0 1.9.2
Transitive dependencies
meta 1.2.2 1.3.0-nullsafety