{"_id":"stats-logger","_rev":"39-cc5a986294653e9772a303d8739395e4","name":"stats-logger","description":"A lightweight application stats tracker and logger","dist-tags":{"latest":"0.2.1"},"versions":{"0.0.1":{"name":"stats-logger","version":"0.0.1","description":"A lightweight application stats tracker and logger","main":"index.js","author":{"name":"Kinvey","email":"support@kinvey.com"},"contributors":[{"name":"Michael Salinger","email":"mjsalinger@kinvey.com"}],"repository":{"type":"git","url":"git://github.com/Kinvey/stats-logger.git"},"scripts":{"test":"mocha"},"keywords":["node","stats","logger","logging"],"dependencies":{"moment":"2.0.x","mutil":"0.3.0"},"devDependencies":{"should":"*","mocha":"*","sinon":"*"},"directories":{"lib":".","test":"test"},"licenses":[{"type":"Apache 2.0","url":"https://github.com/Kinvey/node-background-task/raw/master/LICENSE"}],"engine":{"node":">=0.8"},"optionalDependencies":{},"engines":{"node":"*"},"bugs":{"url":"https://github.com/Kinvey/stats-logger/issues"},"_id":"stats-logger@0.0.1","dist":{"shasum":"ea1a6c59984cd5ccee7ab3fdeec411c64d1d33fe","tarball":"https://registry.npmjs.org/stats-logger/-/stats-logger-0.0.1.tgz","integrity":"sha512-lmPZvAXUr3SZCwhlZ2QlQuIzWOzRq9lN9tzBF9Hr9td15OzlBSX4UuVdJw4cdQmGSy3cb66PlbTRVfUs7YJVfg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGHQ2y/t7dR+Zx3BM7r8xoARrZ1ZWY+sZ6Edf39uO3WHAiAqyrzjN1llIEwZ/FJId2d0jXbwT+p7x36VDvMZfQoEjw=="}]},"_from":".","_npmVersion":"1.2.30","_npmUser":{"name":"mjsalinger","email":"mjsalinger@kinvey.com"},"maintainers":[{"name":"mjsalinger","email":"mjsalinger@kinvey.com"}]},"0.0.3":{"name":"stats-logger","version":"0.0.3","description":"A lightweight application stats tracker and logger","main":"index.js","author":{"name":"Kinvey","email":"support@kinvey.com"},"contributors":[{"name":"Michael Salinger","email":"mjsalinger@kinvey.com"}],"repository":{"type":"git","url":"git://github.com/Kinvey/stats-logger.git"},"scripts":{"test":"mocha"},"keywords":["node","stats","logger","logging"],"dependencies":{"moment":"2.0.x","mutil":"0.3.0"},"devDependencies":{"should":"*","mocha":"*","sinon":"*"},"directories":{"lib":".","test":"test"},"licenses":[{"type":"Apache 2.0","url":"https://github.com/Kinvey/node-background-task/raw/master/LICENSE"}],"engine":{"node":">=0.8"},"optionalDependencies":{},"engines":{"node":"*"},"bugs":{"url":"https://github.com/Kinvey/stats-logger/issues"},"homepage":"https://github.com/Kinvey/stats-logger","_id":"stats-logger@0.0.3","dist":{"shasum":"23c84804cf9b31b8300f94aca692b4cbfbbaa325","tarball":"https://registry.npmjs.org/stats-logger/-/stats-logger-0.0.3.tgz","integrity":"sha512-q7HcQcH78Et8eWpQBseF1oOhZ+yQxkFh8XjK4l5rVZHRiIr5ooxNxJDF6sTxXkq/+0J+8H758bcVPSHamrR5/A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCUXoBqLwk1C/sZDmIlg0VXgWBOQklcAECaqBjQ31gEigIgM2ijiRxmXbIBJKVpBY6YxYamfRp+zc4Sh9jvM692sl4="}]},"_from":".","_npmVersion":"1.3.24","_npmUser":{"name":"mjsalinger","email":"mjsalinger@kinvey.com"},"maintainers":[{"name":"mjsalinger","email":"mjsalinger@kinvey.com"}]},"0.1.0":{"name":"stats-logger","version":"0.1.0","description":"A lightweight application stats tracker and logger","main":"index.js","author":{"name":"Kinvey","email":"support@kinvey.com"},"contributors":[{"name":"Michael Salinger","email":"mjsalinger@kinvey.com"}],"repository":{"type":"git","url":"git://github.com/Kinvey/stats-logger.git"},"scripts":{"test":"mocha"},"keywords":["stats","logger","logging","statistics","node"],"dependencies":{"moment":"2.0.x","mutil":"0.3.0"},"devDependencies":{"should":"*","mocha":"*","sinon":"*","nock":"*"},"directories":{"lib":".","test":"test"},"licenses":[{"type":"Apache 2.0","url":"https://github.com/Kinvey/node-background-task/raw/master/LICENSE"}],"engine":{"node":">=0.8"},"optionalDependencies":{},"engines":{"node":"*"},"bugs":{"url":"https://github.com/Kinvey/stats-logger/issues"},"_id":"stats-logger@0.1.0","dist":{"shasum":"83a3fb694bd31f1ea3ebd0f6797302d3d5cb1753","tarball":"https://registry.npmjs.org/stats-logger/-/stats-logger-0.1.0.tgz","integrity":"sha512-Wbpf/cqmp/4r4PnZhOFOn6UdyIxlASk7SHLw9fYwjoRq8/F3M5pjeWzEdgQh1EDOrlOQrIkCS6X2eVJ/T9ILag==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDVNgA3tTy7Wk4ao1QF5CoNa9ujoMt6r6ARwm87ycjwsAIhAMPV+eeMlPBVgJjxiDc1wEG94zoB2CxdqtafUyxsqGUH"}]},"_from":".","_npmVersion":"1.2.30","_npmUser":{"name":"mjsalinger","email":"mjsalinger@kinvey.com"},"maintainers":[{"name":"mjsalinger","email":"mjsalinger@kinvey.com"}]},"0.1.1":{"name":"stats-logger","version":"0.1.1","description":"A lightweight application stats tracker and logger","main":"index.js","author":{"name":"Kinvey","email":"support@kinvey.com"},"contributors":[{"name":"Michael Salinger","email":"mjsalinger@kinvey.com"}],"repository":{"type":"git","url":"git://github.com/Kinvey/stats-logger.git"},"scripts":{"test":"mocha"},"keywords":["stats","logger","logging","statistics","node"],"dependencies":{"moment":"2.0.x","mutil":"0.3.0"},"devDependencies":{"should":"*","mocha":"*","sinon":"*","nock":"*"},"directories":{"lib":".","test":"test"},"licenses":[{"type":"Apache 2.0","url":"https://github.com/Kinvey/node-background-task/raw/master/LICENSE"}],"engine":{"node":">=0.8"},"optionalDependencies":{},"engines":{"node":"*"},"bugs":{"url":"https://github.com/Kinvey/stats-logger/issues"},"_id":"stats-logger@0.1.1","dist":{"shasum":"3d724ea217944f243997f6f6a3ca5e3b93cbf77a","tarball":"https://registry.npmjs.org/stats-logger/-/stats-logger-0.1.1.tgz","integrity":"sha512-U6SgQf8pWU0R0J2jzq9BWCOkH0YznfBJFjH/NzcJJbzTF/BkVzn3O2PCAUe+ScklkR9EAt/GutpwWouoVE2/OQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIENQnH8SwG3f566+AaHOo8QvbNY6xxhkxzqi7SG5lA08AiAJUv3BdxZ1s2BpkNfpUBGhs5Cosx/yH0f1/heAuEaaRg=="}]},"_from":".","_npmVersion":"1.2.30","_npmUser":{"name":"mjsalinger","email":"mjsalinger@kinvey.com"},"maintainers":[{"name":"mjsalinger","email":"mjsalinger@kinvey.com"}]},"0.1.2":{"name":"stats-logger","version":"0.1.2","description":"A lightweight application stats tracker and logger","main":"index.js","author":{"name":"Kinvey","email":"support@kinvey.com"},"contributors":[{"name":"Michael Salinger","email":"mjsalinger@kinvey.com"}],"repository":{"type":"git","url":"git://github.com/Kinvey/stats-logger.git"},"scripts":{"test":"mocha"},"keywords":["stats","logger","logging","statistics","node"],"dependencies":{"moment":"2.0.x","mutil":"0.3.0"},"devDependencies":{"should":"*","mocha":"*","sinon":"*","nock":"*"},"directories":{"lib":".","test":"test"},"licenses":[{"type":"Apache 2.0","url":"https://github.com/Kinvey/node-background-task/raw/master/LICENSE"}],"engine":{"node":">=0.8"},"optionalDependencies":{},"engines":{"node":"*"},"gitHead":"539a94e1b8675aaa298ae6fb15da2ef8b7fbfc81","bugs":{"url":"https://github.com/Kinvey/stats-logger/issues"},"homepage":"https://github.com/Kinvey/stats-logger","_id":"stats-logger@0.1.2","_shasum":"e22fd5e43d2ea8be66b222ef1611498e8d25c95f","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"mjsalinger","email":"mjsalinger@kinvey.com"},"maintainers":[{"name":"mjsalinger","email":"mjsalinger@kinvey.com"}],"dist":{"shasum":"e22fd5e43d2ea8be66b222ef1611498e8d25c95f","tarball":"https://registry.npmjs.org/stats-logger/-/stats-logger-0.1.2.tgz","integrity":"sha512-V8DdHNi2YMX7PFLCudJqDxLefoCG1VBTXzBKT6RtJ1RcGtyOTD33+WQn6fNZhC/ct0yYN6gCSciaXkMjhfhh1w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBWhSeUfEuvoc9f0Oc1qmfIFk/MgAtpKezG8Cl3grLsXAiEA4J1pUrLWrxTKCpGfqbaf7iXJxPNlRk3NfWirQAz0Ny4="}]}},"0.1.3":{"name":"stats-logger","version":"0.1.3","description":"A lightweight application stats tracker and logger","main":"index.js","author":{"name":"Kinvey","email":"support@kinvey.com"},"contributors":[{"name":"Michael Salinger","email":"mjsalinger@kinvey.com"}],"repository":{"type":"git","url":"git://github.com/Kinvey/stats-logger.git"},"scripts":{"test":"mocha"},"keywords":["stats","logger","logging","statistics","node"],"dependencies":{"moment":"2.0.x","mutil":"0.3.0"},"devDependencies":{"should":"*","mocha":"*","sinon":"*","nock":"*"},"directories":{"lib":".","test":"test"},"licenses":[{"type":"Apache 2.0","url":"https://github.com/Kinvey/node-background-task/raw/master/LICENSE"}],"engine":{"node":">=0.8"},"optionalDependencies":{},"engines":{"node":"*"},"gitHead":"54e6584ad6901ae80003b31d0f4d2f3e6fbc9166","bugs":{"url":"https://github.com/Kinvey/stats-logger/issues"},"homepage":"https://github.com/Kinvey/stats-logger","_id":"stats-logger@0.1.3","_shasum":"1594e603a78854b163c4ac0f9eb931c0b654370a","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"mjsalinger","email":"mjsalinger@kinvey.com"},"maintainers":[{"name":"mjsalinger","email":"mjsalinger@kinvey.com"}],"dist":{"shasum":"1594e603a78854b163c4ac0f9eb931c0b654370a","tarball":"https://registry.npmjs.org/stats-logger/-/stats-logger-0.1.3.tgz","integrity":"sha512-V4HOM1O6ncl6Ie5RKn0SKMxjRDl264dMpHyP36I/GC933E2wXoeXNdCoPo5Hiu4SQzy5GD5JCfeKxmizld5n4Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCVWgYinyia2AAZokviA9aNZypH6Y8hnX2QXGITkuh9CQIhAKeR5xLwpImdhJ4jEx6ZZFX/cyk4SwSDmSEt6nXPCpM1"}]}},"0.1.4":{"name":"stats-logger","version":"0.1.4","description":"A lightweight application stats tracker and logger","main":"index.js","author":{"name":"Kinvey","email":"support@kinvey.com"},"contributors":[{"name":"Michael Salinger","email":"mjsalinger@kinvey.com"}],"repository":{"type":"git","url":"git://github.com/Kinvey/stats-logger.git"},"scripts":{"test":"mocha","eslint":"eslint ."},"keywords":["stats","logger","logging","statistics","node"],"dependencies":{},"devDependencies":{"eslint":"3.19.0","eslint-config-airbnb-base":"9.0.0","eslint-plugin-import":"2.2.0","mocha":"*","nock":"*","should":"*","sinon":"*"},"directories":{"lib":".","test":"test"},"licenses":[{"type":"Apache 2.0","url":"https://github.com/Kinvey/node-background-task/raw/master/LICENSE"}],"engine":{"node":">=0.8"},"optionalDependencies":{},"engines":{"node":"*"},"gitHead":"5ee3bc233c7131bccdbcf0e0bc8706ba9750e180","bugs":{"url":"https://github.com/Kinvey/stats-logger/issues"},"homepage":"https://github.com/Kinvey/stats-logger#readme","_id":"stats-logger@0.1.4","_shasum":"ecac9a280d48f3ef69d0708affa52f3bba215558","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"amaillet","email":"andy@kinvey.com"},"dist":{"shasum":"ecac9a280d48f3ef69d0708affa52f3bba215558","tarball":"https://registry.npmjs.org/stats-logger/-/stats-logger-0.1.4.tgz","integrity":"sha512-b0qGj9zpRyE69vuVs6skBNDoBUc+TXYwgI4QRrYyX0Lsn5OYOjIxx2rrzlgZtv9CIKiYityWxxrBh1J2eQYP1w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBLzC2HtIJqGybcCfpZFFQZgm8J7A98MixEqwQ/t9WA1AiEAzAw11hV1mJA2EkVt8AKX9Vi7HM7l5ESiKxu2bg+6o+8="}]},"maintainers":[{"name":"amaillet","email":"andy@kinvey.com"},{"name":"mjsalinger","email":"mjsalinger@kinvey.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/stats-logger-0.1.4.tgz_1493144474830_0.43116841139271855"}},"0.2.0":{"name":"stats-logger","version":"0.2.0","description":"A lightweight application stats tracker and logger","main":"index.js","author":{"name":"Kinvey","email":"support@kinvey.com"},"license":"Apache-2.0","contributors":[{"name":"Michael Salinger","email":"mjsalinger@kinvey.com"}],"repository":{"type":"git","url":"git://github.com/Kinvey/stats-logger.git"},"scripts":{"test":"mocha","eslint":"eslint ."},"keywords":["stats","logger","logging","statistics","node"],"dependencies":{},"devDependencies":{"eslint":"3.19.0","eslint-config-airbnb-base":"9.0.0","eslint-plugin-import":"2.2.0","google-custom-metrics":"0.10.1","mocha":"3","nock":"*","should":"*","sinon":"1.17.7"},"directories":{"lib":".","test":"test"},"licenses":[{"type":"Apache 2.0","url":"https://github.com/Kinvey/node-background-task/raw/master/LICENSE"}],"engine":{"node":">=0.8"},"optionalDependencies":{},"engines":{"node":"*"},"gitHead":"32a41437c436077632dcb1ffbf0b3e496b7dbda0","bugs":{"url":"https://github.com/Kinvey/stats-logger/issues"},"homepage":"https://github.com/Kinvey/stats-logger#readme","_id":"stats-logger@0.2.0","_shasum":"78403695dc1fe82080667fc1d1eb57248ad8aad5","_from":".","_npmVersion":"2.15.0","_nodeVersion":"8.9.1","_npmUser":{"name":"andrasq","email":"andras@andrasq.com"},"maintainers":[{"email":"andras@andrasq.com","name":"andrasq"},{"email":"andy@kinvey.com","name":"amaillet"},{"email":"mjsalinger@kinvey.com","name":"mjsalinger"}],"dist":{"shasum":"78403695dc1fe82080667fc1d1eb57248ad8aad5","tarball":"https://registry.npmjs.org/stats-logger/-/stats-logger-0.2.0.tgz","integrity":"sha512-6uLXJNvRY3lXsDEqggj9KN3hlgTiCn41ayKVyv2CQb7tkLG5XQvmnkLT7gcxrCZbiAzhAxq4vTXdlr5ykGnTag==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF6OfRIYDJ0nJEbeZVyEhjjugNpfqyz8lHms+vIRkNQdAiAZN2OfU6wKDnFlr4S++Y4Ve5xbqjiUAM4T87v7Gs7ZdQ=="}]},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stats-logger-0.2.0.tgz_1513196691392_0.6222802989650518"}},"0.2.1":{"name":"stats-logger","version":"0.2.1","description":"A lightweight application stats tracker and logger","main":"index.js","author":{"name":"Kinvey","email":"support@kinvey.com"},"license":"Apache-2.0","contributors":[{"name":"Michael Salinger","email":"mjsalinger@kinvey.com"}],"repository":{"type":"git","url":"git://github.com/Kinvey/stats-logger.git"},"scripts":{"test":"mocha","eslint":"eslint ."},"keywords":["stats","logger","logging","statistics","node"],"dependencies":{"google-custom-metrics":"0.10.1"},"devDependencies":{"eslint":"3.19.0","eslint-config-airbnb-base":"9.0.0","eslint-plugin-import":"2.2.0","mocha":"3","nock":"*","should":"*","sinon":"1.17.7"},"directories":{"lib":".","test":"test"},"licenses":[{"type":"Apache 2.0","url":"https://github.com/Kinvey/node-background-task/raw/master/LICENSE"}],"engine":{"node":">=0.8"},"optionalDependencies":{},"engines":{"node":"*"},"gitHead":"73daf0bfea212cc31793532c56bbb7989358c7de","bugs":{"url":"https://github.com/Kinvey/stats-logger/issues"},"homepage":"https://github.com/Kinvey/stats-logger#readme","_id":"stats-logger@0.2.1","_npmVersion":"5.5.1","_nodeVersion":"8.9.2","_npmUser":{"name":"amaillet","email":"andy@kinvey.com"},"dist":{"integrity":"sha512-JwhCq4ARqh669oxlenCiUDVc4mZrew/FXuwx2FMDZDiByDt9ruHuvWA9rohZUSrHWAQBkFbZh5icbzrBhsMnxA==","shasum":"b20958dc0ca69264054d44957b1af767cd606136","tarball":"https://registry.npmjs.org/stats-logger/-/stats-logger-0.2.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCQ12kmvJNR6lmeHE8sjRyNbyiLWSxHYLyJJtcOl4YPzwIhAJJM+ww6fed9J/2MlZOnNV3qdt7T4niTAjUGnh/RsPK1"}]},"maintainers":[{"email":"andras@andrasq.com","name":"andrasq"},{"email":"andy@kinvey.com","name":"amaillet"},{"email":"mjsalinger@kinvey.com","name":"mjsalinger"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/stats-logger-0.2.1.tgz_1513263329369_0.1774723557755351"}}},"readme":"# stats-logger\n\nA lightweight node module for capturing application statistics and writing them to a specified backend.  \n\nThe goal of this module is to provide a single consistent interface to capture a wide variety of application statistics, and record those statistics to an independent backend (e.g. a text file stats log, a redis instance, StackDriver, etc.).  \n\n## Installation\n\n```\n$ npm install stats-logger\n```\n\n## Usage\n\nOnce configured, stats are easily tracked by calling recordStat. \n\n```\nvar stats = require('stats-logger').createInstance(60000, 'file', {filename: './stats.log', outputFormat: \"{lastFlushTime} {myStat1} {myStat2}\");\n\nstats.addStat(\"myStat1\", \"counter\");\nstats.addStat(\"myStat2\", \"max\");\nstats.addStat(\"myStat3\", \"snapshot\");\n\nstats.start();\n\nrecordStat(\"myStat1\", 1);\nrecordStat(\"myStat2\", 15);\nrecordStat(\"myStat3\", 25);\n```\n\n## API\n\n### createInstance(flushInterval, backend, backendConfig, [stats])\n\nCreates an instance of stats logger, with the following arguments:\n\n* `flushInterval` time in ms between flushing stats to the backend\n* `backend` the type of backend\n* `backendConfig` a JSON object containing backend-specific configuration options\n* `stats` an optional JSON object containing stats to be initialized\n\nIn this example, a statsLogger is initialized with a flushInterval of 60 seconds, and will output to a file stats.log in the current directory.  A stat called __myStat1__ will be initialized.  \n\n```\nvar backendConfig = {filename: \"./stats.log\"\", outputFormat: \"{lastFlushTime} {lastFlushTimeUnix {myStat1}\"};\nvar initialStats = {myStat1: {type: \"counter\", options: {initialValue: 1}};\n\nvar stats = require('stats-logger').createInstance(60000, 'file', backendConfig, initialStats);\n```\n### addStat(name, type, options)\n\nAdds a stat to be tracked.  Takes the following arguments:\n\n* `name` the unique of the stat to be tracked\n* `type` the type of stat to be tracked\n* `options` stat-specific options\n\n```\nstats.addStat(\"myStat\", \"counter\", {initialValue: 1, resetValue: 0});\n```\n\n### removeStat(name)\n\nRemoves the stat with the specified `name`\n\n### recordStat(name, value)\n\nRecords a stat called `name` with the value `value`.  \n\n### getStatValue(name)\n\nGets the current value of the stat `name`\n\n### start()\n\nStarts the flushing of stats at every time interval specified by `flushInterval`\n\n### stop()\nStops the flushing of stats\n\n### end()\n\nCloses the connection to the backend, and removes all stat tracking\n\n### flush()\n\nManually flushes stats to the configured backend\n\n## Stat Types\n\n### counter\n\nIncrement and decrement by the passed value.  If no value is passed, automatically defaults to incrementing by 1, or by the supplied incrementFactor.  \n\nOptions: \n\n* `initialValue` The initial value of the counter.  Defaults to 0.  \n* `resetValue` The value to reset the counter by after each flush.  Defaults to 0.\n* `incrementFactor` The value to increment by if no value is passed.  Defaults to 1.\n* `suppressReset` if true, then does not reset the counter on flush. Defaults to false.\n\n```\naddStat(\"myStat\", \"counter\", {initialValue: 1, resetValue: 1, incrementFactor: 2});\n\n\nrecordStat(\"myStat\");  // value is now 3\nrecordStat(\"myStat\");  // value is now 5\nrecordStat(\"myStat\", 1); // value is now 6\nrecordStat(\"myStat\", -3); // value is now 3\n```\n\n### max\n\nTracks the maximum value of all values passed during the flush interval.   \n\nOptions: \n\n* `initialValue` The initial value of the counter.  Defaults to null.\n* `resetValue` The value to reset the counter by after each flush.  Defaults to null.\n* `suppressReset` if true, then does not reset the counter on flush. Defaults to false.\n\n```\naddStat(\"myStat\", \"max\", {initialValue: 1, resetValue: 1});\n\n\nrecordStat(\"myStat\", 3);  // value is 3\nrecordStat(\"myStat\", 5);  // value is 5\nrecordStat(\"myStat\", 1); // value is 5\nrecordStat(\"myStat\", -3); // value is 5\n```\n\n### min\n\nTracks the minimum value of all values passed during the flush interval.   \n\nOptions: \n\n* `initialValue` The initial value of the counter (defaults to ). Defaults to null.\n* `resetValue` The value to reset the counter by after each flush.  Defaults to null.\n* `suppressReset` if true, then does not reset the counter on flush. Defaults to false.\n\n```\naddStat(\"myStat\", \"min\", {initialValue: 1, resetValue: 1});\n\n\nrecordStat(\"myStat\", 3);  // value is 3\nrecordStat(\"myStat\", 5);  // value is 3\nrecordStat(\"myStat\", 1); // value is 1\nrecordStat(\"myStat\", -3); // value is -3\n```\n\n### snapshot\n\nA static value snapshot - set to the value passed at every recording of the stat.  \n\nOptions: \n\n* `initialValue` The initial value of the counter (defaults to ). Defaults to null.\n* `resetValue` The value to reset the counter by after each flush.  Defaults to null.\n* `suppressReset` if true, then does not reset the counter on flush. Defaults to false.\n\n```\naddStat(\"myStat\", \"min\", {initialValue: 1, resetValue: 1});\n\n\nrecordStat(\"myStat\", 3);  // value is 3\nrecordStat(\"myStat\", 5);  // value is 5\nrecordStat(\"myStat\", 1); // value is 1\nrecordStat(\"myStat\", -3); // value is -3\n```\n\n### mean\n\nCalculates the mean of values passed. \n\nThere are two types of means - count means, which calculate the mean as the sum of the values passed / number of times recordStat is invoked, and stat means, which calculate the mean as the sum of the values passed / some other stat that is being tracked.  \n\n* `meanType` 'count' or 'stat', the type of mean.  Defaults to 'count'.  \n* `divisorStat` If meanType is 'stat', the name of the stat to use as the divsior.\n* `dividendStat` If meanType is 'stat', the name of the stat to use as the dividend\n* `initialValue` The initial value of the counter (defaults to ). Defaults to null.\n* `resetValue` The value to reset the counter by after each flush.  Defaults to null.\n* `suppressReset` if true, then does not reset the counter on flush. Defaults to false.\n* `fractionDigits` the number of fracitonal digits to the right of the decimal place to round to\n\nSample count mean type\n\n```\naddStat(\"myStat\", \"mean\");\n\n\nrecordStat(\"myStat\", 3);  // value is 3 / 1 = 3\nrecordStat(\"myStat\", 5);  // value is 8 / 2 = 4\nrecordStat(\"myStat\", 1); // value is 9 / 3 = 3\nrecordStat(\"myStat\", -3); // value is 6 / 4 = 2.5\n```\n\nSample stat mean type, with only a divisor stat\n\n```\naddStat(\"baseStat\", \"counter\");\naddStat(\"myStat\", \"mean\", {meanType: 'stat', divisorStat: 'baseStat');\n\nrecordStat('baseStat', 10);\n\n\nrecordStat(\"myStat\", 30);  // value is 30 / 10 = 3\nrecordStat(\"myStat\", 20);  // value is 40 / 10 = 5\n\nrecordStat(\"baseStat\", 15); // value of baseStat is now 25, and value of myStat is now 2\n\nrecordStat(\"myStat\", 25); // value is 75 / 25 = 3\n```\n\nSample stat mean type, with both a divisor and dividend stat\n\n```\naddStat(\"baseStat\", \"counter\");\naddStat(\"baseStat2\", \"snapshot\");\naddStat(\"myStat\", \"mean\", {meanType: 'stat', divisorStat: 'baseStat', dividendStat: 'baseStat2');\n\nrecordStat('baseStat', 10);\nrecordStat('baseStat2', 50); // value is 50 / 10 = 25\n\n\nrecordStat(\"baseStat2\", 30);  // value is 30 / 10 = 3\nrecordStat(\"baseStat2\", 20);  // value is 20 / 10 = 2\n\nrecordStat(\"baseStat\", 20); // value of baseStat is now 20, and value of myStat is now 1\n\nrecordStat(\"baseStat2\", 40); // value is 40 / 20 = 2\n```\n\n### calculated\n\nMonitors multiple stats and calculates a value based on a provided calculation function\n\nOptions:\n\n* `stats` An array of stats to monitor.  The calculation function will be invoked whenever any stat in the array is updated\n* `calcFunction` The calculation function, which takes two arguments:\n  * stats:  An array consisting of the names of the stats that are part of the calculation\n  * statsMap:  an object containing the current value of each stat\n* `suppressReset` if true, then does not reset the counter on flush. Defaults to false.\n\nSample calculated function\n```\n\nvar calcFunction = function(stats, statsMap) {\n  return statsMap.stat1 * statsMap.stat2 / (statsMap.stat3 !== 0 ? statsMap.stat3 : 1);\n};\n\naddStat(\"stat1\", \"counter\");\naddStat(\"stat2\", \"min\");\naddStat(\"stat3\", \"snapshot\");\naddStat(\"calcStat, \"calculated, {stats: ['stat1','stat2','stat3], calcFunction: calcFunction});\n\nrecordStat(\"stat1\", 25); // value is 25 * null / 1 = null\nrecordStat(\"stat2\", 10); // value is 25 * 10 / 1 = 200\nrecordStat(\"stat2\", 15); // value is 25 * 10 / 1 = 200\nrecordStat(\"stat3\": 25); // value is 25 * 10 / 25 = 10\n```\n\n## Backends\n\n### File\n\nThe file backend flushes the stats to a file according to a specified string template.\n\nBackend Options:\n* `filename` The full path to the log file to be written to\n* `outputFormat` The format string used to write stats.  \n\nThe `outputFormat` template takes the name of the stat enclosed in {}.  There are also special tags that can be used to output the time the stats were flushed:  \n\n* `lastFlushTime` outputs the date and time in human-readable format\n* `lastFlushTimeUnix` outputs the unix timestamp\n\n### StackDriver\n\nThe StackDriver backend flushes the stats to StackDriver\n\nBackend Options\n* `apiKey` The API Key for accessing the StackDriver stats submission API\n* `source` (optional) the name of the Amazon Instance ID to map the stats to, in the format i-XXXXXXXX\n* `statsMap` A JSON object containing keys indicating the name of the stats in stats-logger, mapped to the values of StackDriver\n  custom metrics\n\n\n","maintainers":[{"email":"andras@andrasq.com","name":"andrasq"},{"email":"andy@kinvey.com","name":"amaillet"},{"email":"mjsalinger@kinvey.com","name":"mjsalinger"}],"time":{"modified":"2022-06-27T00:07:21.620Z","created":"2014-02-13T23:13:36.284Z","0.0.1":"2014-02-13T23:13:37.335Z","0.0.2":"2014-02-20T21:11:25.730Z","0.0.3":"2014-02-20T22:16:43.149Z","0.1.0":"2014-03-17T19:13:00.669Z","0.1.1":"2014-03-21T14:38:40.249Z","0.1.2":"2015-01-30T12:51:41.035Z","0.1.3":"2015-03-13T10:37:16.620Z","0.1.4":"2017-04-25T18:21:15.494Z","0.2.0":"2017-12-13T20:24:51.505Z","0.2.1":"2017-12-14T14:55:30.399Z"},"readmeFilename":"README.md","author":{"name":"Kinvey","email":"support@kinvey.com"},"repository":{"type":"git","url":"git://github.com/Kinvey/stats-logger.git"},"keywords":["stats","logger","logging","statistics","node"],"contributors":[{"name":"Michael Salinger","email":"mjsalinger@kinvey.com"}],"bugs":{"url":"https://github.com/Kinvey/stats-logger/issues"},"homepage":"https://github.com/Kinvey/stats-logger#readme","license":"Apache-2.0"}