Coder Social home page Coder Social logo

emosd's Introduction

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

emosd's People

Contributors

synw avatar

Stargazers

O. Libre avatar  avatar

Watchers

James Cloos avatar  avatar  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.