Giter Site home page Giter Site logo

logging-timer's Introduction

logging-timer

Better time logging in your Javascript application. This is a more comprehensive way to log timestamps than the native console.time APIs as this being equally performant with better messages in logging.

Installation

In terminal, navigate to your project directory and run

npm install logging-timer

Then in your project's .js/.ts file, do

import LoggingTimer from 'logging-timer';

const timer1 = new LoggingTimer();

Usage

const timer1 = new LoggingTimer({
    name: "Timer 1"
});

timer1.start(); // Will print a start messages

setTimeout(() => {
    timer1.lap(); // First Lap
}, 2000);

setTimeout(() => {
    timer1.lap(); // Second Lap
}, 4000);

setTimeout(() => {
    timer1.stop(); // Stop the timer
}, 4000);

// You can start timer1 here again.

Options

This package supports various options to configure how the logger works. Use these to suit your needs.

Parameter Type Default Description
name string "" Name of the timer
logging boolean true Decides if you want log on every lap and stop
logger {log: Function; warn: Function} {log: console.log, warn: console.warn} Pass custom logger methods

For example:

const timer1 = new LoggingTimer({
    name: "Timer 1",
    logging: true,
    logger: {
        log: console.log,
        warn: console.log
    }
})

Support

Log a issue or reach out to me at [email protected]

logging-timer's People

Watchers

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