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 = ;//mark ;
Usage examples
Print log in the console:
// initialize const perf = ; // mark the point ; const response = await axios; // mark again. so between this two perf() calls it logs the time in the console ;
If you dont wish to log into the console,
// initialize const perf = inLineLog:false; // mark the point ; const response = await axios; // mark again. ;
Now console logs wont be there. To get the performance details. The way is using perf._summary
console;
To get all the performance logs :
; const response = await axios; // mark again. so between this two perf() calls it logs the time in the console ; ; await db; ; const summary = perf_summary; console;
Output:
Options:
const perf = enabled:true inLineLog:true round:2 logPrefix:"PERF:" ;
Options | description |
---|---|
enabled | To enable/disable library logging. If set to true, logging will be disabled. Default: true |
inLineLog | DEFAULT:true. if enabled, on the 2nd mark, it will console log the performance. |
round | DEFAULT:2, round off value. |
logPrefix | DEFAULT: '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.