staged-process-logger

Pretty logging for processess in console by stages.


License
WTFPL
Install
npm install staged-process-logger@0.0.2

Documentation

Staged Process Logger

Pretty logging for processess in console by stages.

Example without data

Example with mocked data

Getting started

npm i staged-process-logger
import {StagedProcess} from 'staged-process-logger';

const success = await StagedProcess( "Process you want to log", {
    "Stage 1": async (message, status) => {
        await wait(200);
        message("Something - 1");
        await wait(700);
        message("Something - 2");
        await wait(200);
        message("Something - 3");
        status.success();
    },
    "Stage 2": async (message, status) => {
        await wait(200);
        message("Something - 1");
        await wait(700);
        message("Something - 2");
        await wait(200);
        message("Something - 3");
        status.success();
    },
    "This one will fail!": async (message, status) => {
        await wait(200);
        message("Something - 1");
        await wait(700);
        message("Something - 2");
        await wait(200);
        message("Something - 3");
        throw new Error("OOF");
    },
    "Skipped because the previous failed": async (message, status) => {
        // do nothing
    },

});

// Will be {success : false} as it failed
console.log({success});

Detailed usage

The status object has a few attributes you can call:

status : {

    // Mark as successfull
    success 

    // Mark as failed (also triggered by any thrown error)
    fail 

    // Skip this stage, runs next immediately
    skip 

}

Contribution

Run yarn watch to build it continiously while you edit

yarn watch

Push to npm with deploy (which builds and publishes)

yarn deploy