0.4.0 • Published 1 year ago

emosd v0.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Emosd

pub package

Emoji based semantic debuging

  • Debug the state and execution flow of your program using familiar idioms
  • Scoped debuging: activate emo locally
  • Hooks: callback to execute after logging

Install

npm install emosd

or

yarn add emosd

Example

import Emo from "./emosd";

const emo = new Emo();
const zone2 = new Emo({ zone: "zone2" });
const zone3 = new Emo({ zone: "zone3", hook: (v) => { console.log("Zone 3 hook for", v) } });

async function run() {
emo.section("Run");
emo.state("A state operation");
emo.save("Saving something", { foo: "bar" });
emo.delete("Deleting something");
emo.update("Updating something");
emo.ok("Everything is ok");
zone2.start("Start");
zone2.transmit({ foo: "bar" });
zone2.notFound("Something not found");
zone3.warning("a warning");

Console output:

Example

Scoped debuging

The recommended way is to use local Emo 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 emo = new Emo({ zone: "api" });
// the messages will be prefixed by [api] :
emo.notFound(`page not found: ${path}`);
// output:
// 🚫 [api] Page not found: /some_page.html

Deactivation of output

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

const emo = new Emo({ deactivatePrint: true });

Hooks

Callbacks to execute after logging. Ex:

const emo = new Emo({ 
  hook: (msg) => { console.log(`Hook with message ${msg}`); }
});

Print some json data in console

const data = { foo: "bar" };
emo.json(data);
// or
Emo.json(data);
0.4.0

1 year ago

0.3.0

2 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.0

3 years ago

0.0.3

3 years ago

0.1.1

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago