This repository has moved to https://github.com/teal-finance/emo
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:
Note: this is not for error management, you can use Err and ErrRouter to manage the errors.
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
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}
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 zone
attribute to prefix the messages:
const EmoDebug _ = EmoDebug(zone: "http service");
// the messages will be prefixed by [http service] :
_.notFound(path, "page not found");
// output:
// ๐ซ [http service] Page not found: /some_page.html
It is possible to deactivate the printing of the messages for an instance:
// on top of a file
const EmoDebug debug = EmoDebug(deactivatePrint: true);
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");