3.0.0 • Published 4 years ago

perflog v3.0.0

Weekly downloads
45
License
ISC
Repository
github
Last release
4 years ago

#PERFLOG

A simple performance logger. No external library. Not tested in production. It can be used for debugging and development environment.

##Syntax

// declarion
     const perf = require("perflog")();
//mark
     perf("apiCall");

##Usage examples

Print log in the console:

    // initialize 
    const perf = require("perflog")();
   
    // mark the point
    perf("apiCall");
    const response = await axios.get();
    // mark again. so between this two perf() calls it logs the time in the console
    perf("apiCall");

If you dont wish to log into the console,

     // initialize 
        const perf = require("perflog")({inLineLog:false});
       
        // mark the point
        perf("apiCall");
        const response = await axios.get();
        // mark again.
        perf("apiCall");

Now console logs wont be there. To get the performance details. The way is using perf._summary

    console.log(perf._summary);

To get all the performance logs :

    perf("apiCall");
    const response = await axios.get();
    // mark again. so between this two perf() calls it logs the time in the console
    perf("apiCall");
    
    perf("db");
    await db.create(data);
    perf("db");

    const summary = perf._summary;
    console.log(summary);

Output:

    {
      "apiCall": "1160.50",
      "db": "1113.13"
    }

##Options:

   const perf = require("perflog")({
       enabled:true,
       inLineLog:true, 
       round:2,
       logPrefix:"PERF:"
   });
Optionsdescription
enabledTo enable/disable library logging. If set to true, logging will be disabled. Default: true
inLineLogDEFAULT:true. if enabled, on the 2nd mark, it will console log the performance.
roundDEFAULT:2, round off value.
logPrefixDEFAULT: 'PERF:'

Environment configuration

####PERF_LOG : If PERF_LOG is set to false, all the logging will be disabled. No in line logging and no logging report in perf._summary object.

3.0.0

4 years ago

2.2.1

4 years ago

2.2.0

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago