easy-stat

a tiny tool for stat some variables in node apps

Usage no npm install needed!

<script type="module">
  import easyStat from 'https://cdn.skypack.dev/easy-stat';
</script>

README

About

this is a tiny tool for recording and writing some statistic data to log files.

Usage

npm install easy-stat --save

// 'demo' is the name for identifying from different instances of EasyStat;

var opt = {
  interval: 10000,  // interval value in 'ms' for writing data to log file
  logger: console.log  // method to write log data
};

var demoStat = require('esay-stat')('demo', opt);
demoStat.launch();

// some where need to record the count of calling an api
// here I want record api_called for 5 times
demoStat.touch('api_called', 5);

then the demoStat will sum and write the total api_called to the log file which would looks like:

// name.key         timestamp  value
demoStat.api_called 1463582916 136