Giter Site home page Giter Site logo

yorker's Introduction

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.');
    });
}

yorker's People

Contributors

ddoronin avatar

Stargazers

 avatar

Watchers

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