emodebug 0.2.0 emodebug: ^0.2.0 copied to clipboard
Emoji based semantic debuging. Debug the state and execution flow of a program with familiar idioms
Emodebug #
Emoji based semantic debuging:
- Debug the state and execution flow of your program using familiar idioms
- 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.
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 and deactivation #
The recommended way is to use local EmoDebug
instances to be able to enable and disable debug messages for a defined portion of code:
// on top of a file
const EmoDebug debug = EmoDebug(deactivate: false);
To deactivate debug messages for this instance set to 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");