0.1.6 • Published 5 years ago

yorker v0.1.6

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

Yorker

GitHub license npm version Build Status

NodeJS library for nice & easy console logs.

Quick Start

Install using yarn or npm.

$ yarn add yorker
$ npm install yorker --save

Import in one of your js, ts or vue files and start using it.

import { yorker } from 'yorker';

const say = yorker.see('something');
say('something');

By default it will be switched off for production enviroment NODE_ENV="production".

Advanced Setup

Create a file in your project to have a singlethon instance of the logger. To instantiate the Yorker class you need two parameters to set up: Theme and the flag enabled.

import { Yorker, NYPDTheme } from 'yorker';

const theme = new NYPDTheme();
const enabled = process.env.NODE_ENV !== 'production';
export const newYorker = new Yorker(theme, enabled);

A new custom theme can be created by implementing the ITheme interface.

API

It's very easy and has only one method see(msg) that returns a function say(msg, error?).

const say = yorker.see('something');
say('everything is Okay');
say('there is an error', new Error('smth'));

Example

function startMongo(config: { url: string }) {
    const say = yorker.see(`Connecting to mongo: "${config.url}"`);
    const client = new MongoClient(config.url, { raw: true, useNewUrlParser: true });
    client.connect((err, client) => {
        if (err) {
            say('Error while connecting to mongo.', err);
            return process.exit(1);
        }
        say('Connection to mongo succeeded.');
    });
}
0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago