{"_id":"@anandsuresh/smart-log","_rev":"6-f38e657be18d9449a50cee1547975b9d","name":"@anandsuresh/smart-log","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@anandsuresh/smart-log","version":"1.0.0","description":"A smart log-agent and log-sinks","license":"MIT","main":"index.js","repository":{"type":"git","url":"git+https://github.com/anandsuresh/smart-log.git"},"author":{"name":"Anand Suresh"},"bugs":{"url":"https://github.com/anandsuresh/smart-log/issues"},"homepage":"https://github.com/anandsuresh/smart-log#readme","scripts":{"coverage":"NODE_ENV=test istanbul cover -i 'lib/**/*.js' _mocha -- --ui bdd --reporter spec --recursive spec && open coverage/lcov-report/index.html > /dev/null 2>&1","lint":"standard","test":"mocha --ui bdd --reporter spec --recursive spec"},"dependencies":{"@anandsuresh/smart-queue":"^1.0.0","moment":"2.21.0"},"devDependencies":{"chai":"4.1.2","istanbul":"1.1.0-alpha.1","mocha":"5.0.5","sinon":"5.0.0","standard":"11.0.1"},"standard":{"ignore":[],"globals":["after","afterEach","before","beforeEach","describe","it"]},"gitHead":"9ff5a2449aeabe598d5fa762ee35c90e9f60535b","_id":"@anandsuresh/smart-log@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.9.0","_npmUser":{"name":"anandsuresh","email":"anandsuresh@gmail.com"},"dist":{"integrity":"sha512-0ICIAH9hMOqvGSf5RxsXkPfz3jwPNyUyid/MAE37J9hTBAS8bzUyqkCqQh/JH+8CNCiW6miNcu6vtfwNtrUZeA==","shasum":"bc2ab64e0b3305c273f0361bbf406c1f19cc5a1f","tarball":"https://registry.npmjs.org/@anandsuresh/smart-log/-/smart-log-1.0.0.tgz","fileCount":14,"unpackedSize":32093,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQD/GvQJmYss1pblsdixszN3hjhsJGREI7X3hjz8WXo2UgIhALoJB8fuSG0KPxK06oY0ypzBirFgCif150So2DZCLOgk"}]},"maintainers":[{"name":"anandsuresh","email":"anandsuresh@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/smart-log_1.0.0_1522518789163_0.13464480051502248"},"_hasShrinkwrap":false},"1.0.1":{"name":"@anandsuresh/smart-log","version":"1.0.1","description":"A smart log-agent and log-sinks","license":"MIT","main":"index.js","repository":{"type":"git","url":"git+https://github.com/anandsuresh/smart-log.git"},"author":{"name":"Anand Suresh"},"bugs":{"url":"https://github.com/anandsuresh/smart-log/issues"},"homepage":"https://github.com/anandsuresh/smart-log#readme","engines":{"node":">=8.0.0"},"scripts":{"coverage":"NODE_ENV=test istanbul cover -i 'lib/**/*.js' _mocha -- --ui bdd --reporter spec --recursive spec && open coverage/lcov-report/index.html > /dev/null 2>&1","lint":"standard","test":"mocha --ui bdd --reporter spec --recursive spec"},"dependencies":{"@anandsuresh/smart-queue":"^1.0.0","moment":"2.21.0"},"devDependencies":{"chai":"4.1.2","istanbul":"1.1.0-alpha.1","mocha":"5.0.5","sinon":"5.0.0","standard":"11.0.1"},"standard":{"ignore":[],"globals":["after","afterEach","before","beforeEach","describe","it"]},"gitHead":"c43841266cfe5f03245f4507c76f87f0e432dfaf","_id":"@anandsuresh/smart-log@1.0.1","_shasum":"d9287c47380dbd8c593829cab0c9c6c6b6928545","_from":".","_npmVersion":"3.10.10","_nodeVersion":"6.10.2","_npmUser":{"name":"anandsuresh","email":"anandsuresh@gmail.com"},"dist":{"shasum":"d9287c47380dbd8c593829cab0c9c6c6b6928545","tarball":"https://registry.npmjs.org/@anandsuresh/smart-log/-/smart-log-1.0.1.tgz","fileCount":16,"unpackedSize":130397,"integrity":"sha512-uXdIo32Zhwo991TCcld0aR8HVJrPbSaMJjMYwgzb0Wirf2r68azFB744KAo7mIa9hKFhQU5Ev11vi8mPtoURLQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDz5subu/hdIuGJcy7MKS0GZ2mIMrQ1MwD6eor4cv7PwAIgX61Nnzog2ffY73sh4y8xcSxNLiXlS7PtzEge2Fy/fM4="}]},"maintainers":[{"name":"anandsuresh","email":"anandsuresh@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/smart-log_1.0.1_1522519573719_0.9031257279261073"},"_hasShrinkwrap":false},"1.0.2":{"name":"@anandsuresh/smart-log","version":"1.0.2","description":"A smart log-agent and log-sinks","license":"MIT","main":"index.js","repository":{"type":"git","url":"git+https://github.com/anandsuresh/smart-log.git"},"author":{"name":"Anand Suresh"},"bugs":{"url":"https://github.com/anandsuresh/smart-log/issues"},"homepage":"https://github.com/anandsuresh/smart-log#readme","engines":{"node":">=8.0.0"},"scripts":{"coverage":"NODE_ENV=test istanbul cover -i 'lib/**/*.js' _mocha -- --ui bdd --reporter spec --recursive spec && open coverage/lcov-report/index.html > /dev/null 2>&1","lint":"standard","test":"mocha --ui bdd --reporter spec --recursive spec"},"dependencies":{"@anandsuresh/smart-queue":"^1.0.0","moment":"2.21.0"},"devDependencies":{"chai":"4.1.2","istanbul":"1.1.0-alpha.1","mocha":"5.0.5","sinon":"5.0.0","standard":"11.0.1"},"standard":{"ignore":[],"globals":["after","afterEach","before","beforeEach","describe","it"]},"gitHead":"7521a14b4dd58e98111e5e716218b648bf778839","_id":"@anandsuresh/smart-log@1.0.2","_npmVersion":"6.1.0","_nodeVersion":"10.7.0","_npmUser":{"name":"anandsuresh","email":"anandsuresh@gmail.com"},"dist":{"integrity":"sha512-MyLyjTLIIYeTZ9sGAzxm09XWdeVHwfrrY5EzEYeCTdaen7M3HZU6sPMC0o2E34IbfJcun0DhTi1cjRD2S7jdHQ==","shasum":"4e6bec462314178031c218c6b937b88320439c08","tarball":"https://registry.npmjs.org/@anandsuresh/smart-log/-/smart-log-1.0.2.tgz","fileCount":14,"unpackedSize":32432,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbWML2CRA9TVsSAnZWagAAO/AP/AvjYbLG8EWC9SgDaucr\nK6nWic3rfNEvLjE2jH9LcYg1BVa2mHql68wrNbV/B3OYH+/m7lIW3uEkiY+e\nepM48gvNJQJxBf1z2H6v7s002F3MEE7H6eRoCNrdH1XZe1MLjgFq8yWDrXDe\nKDTSjbZzwKHmbB6pr4IPimod3W0rT0Ev7yJezrsw5IekkMeCKBoWgkIHjM1l\nG0sqSceBH7Q3eq70ZVslRLpXDWiLKkjv0NRy0KO2vL2wDHNCF15+9/pmG+xt\ndClrb2n2GXXaJGuNerXRVnvU0m+vbnPJlGCihCNI9eVk2CvXz3LnceRz8hWH\n2PaeP9nbVW2tUIJLx2NU0G661HkXvx7bPwIA/CN7vXH7aPzAKWyhuTn3l8HP\nOzqb1flE4NH8b6uab13n6K8LADm5h9YXAOKowY2s6/IsQVwmDTPi278TTNl3\nMqhTdGEtLh079kAVktjpL3mHKdH02la2D+g0aw4Dz5sifQIY159/6Ha3Owq6\neka1ldUHTbGe5GHa8/GTtHtJKFZLoa4uF0WepnnGrYH14+6g141EPae/xYIM\nXjpiPbFRBOSyQ9b0Milu20kCVt5NE2hZGGYxkNvYHuU0H9KJqlveVgKxNmUp\nQeZJJiTbU+pdr1n6GGAwIkN7F7OuKq+p8U8qJvYZTl3NTaEPkLfaz93L0p7p\nesIb\r\n=L323\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDCyHYr6dewh+f+qpJ3kwk2/GxXtH3s8oC5NDOf7X9cvgIgduKNB5s3PS939Y1RsbagJd4v4I/lxFOwYFfnmZLIyYA="}]},"maintainers":[{"name":"anandsuresh","email":"anandsuresh@gmail.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/smart-log_1.0.2_1532543734388_0.5311044822342068"},"_hasShrinkwrap":false}},"time":{"created":"2018-03-31T17:53:09.112Z","1.0.0":"2018-03-31T17:53:09.245Z","modified":"2022-06-12T14:40:17.125Z","1.0.1":"2018-03-31T18:06:13.828Z","1.0.2":"2018-07-25T18:35:34.709Z"},"maintainers":[{"name":"anandsuresh","email":"anandsuresh@gmail.com"}],"description":"A smart log-agent and log-sinks","homepage":"https://github.com/anandsuresh/smart-log#readme","repository":{"type":"git","url":"git+https://github.com/anandsuresh/smart-log.git"},"author":{"name":"Anand Suresh"},"bugs":{"url":"https://github.com/anandsuresh/smart-log/issues"},"license":"MIT","readme":"# smart-log\n\n[![node (scoped)](https://img.shields.io/node/v/@anandsuresh/smart-log.svg?style=plastic)](https://nodejs.org/en/download/)\n[![npm (scoped)](https://img.shields.io/npm/v/@anandsuresh/smart-log.svg?style=plastic)](https://www.npmjs.com/package/@anandsuresh/smart-log)\n[![npm](https://img.shields.io/npm/dt/@anandsuresh/smart-log.svg?style=plastic)](https://www.npmjs.com/package/@anandsuresh/smart-log)\n[![Travis](https://img.shields.io/travis/anandsuresh/smart-log.svg?style=plastic)](https://travis-ci.org/anandsuresh/smart-log)\n[![license](https://img.shields.io/github/license/anandsuresh/smart-log.svg?style=plastic)](LICENSE)\n[![GitHub followers](https://img.shields.io/github/followers/anandsuresh.svg?style=social&label=Follow)](https://github.com/anandsuresh)\n[![Twitter Follow](https://img.shields.io/twitter/follow/anandsuresh.svg?style=social&label=Follow)](https://twitter.com/intent/follow?screen_name=anandsuresh)\n\nThe smart-log module provides a set of modules to log information to one or more log sinks. It consists of a singleton log agent implemented as a `Readable` object stream and exposes logging/metrics methods. The agent can be piped into one or more `Writable` log sinks including:\n- `ConsoleSink`: writes the `process.stderr`\n- `SyslogSink`: writes to the specified syslog server\n- `RotatingFileSink`: writes to a local file and rotates it at the start of each new day\n\n## usage\n\n```\nconst SmartLog = require('@anandsuresh/smart-log')\n\n// Initialize the log agent to:\n// - log things at info and lower\n// - log the process pid in each log message\n// - queue up to 1000 of the latest log items if the sink(s) is/are slow\nconst log = SmartLog.init({\n  level: 'info',\n  default: { pid: process.pid },\n  queue: { strategy: 'overwrite', size: 1000 }\n})\n\n// Log everything from the agent to stderr\nconst stderr = SmartLog.createConsoleSink()\n\n// Log notice and above to a file\nconst rotatingFile = SmartLog.createRotatingFile({\n  filter: log => ~['debug', 'info', 'notice'].indexOf(log.level),\n  path: '/var/log', // make sure your process has write privileges at this path\n  prefix: 'log-',   // log file name prefix; date will be appended to this\n  suffix: '.log'    // log file name suffix; will be appended to the end of the file name\n})\n\n// Only log warning and below to syslog\nconst syslog = SmartLog.createSyslogSink({\n  filter: log => ~['warning', 'error', 'critical', 'alert', 'emergency'].indexOf(log.level),\n  id: process.pid,        // unique name reported to syslog\n  hostname: '127.0.0.1',  // hostname/IP address of the syslog daemon\n  port: 514,              // TCP port of the syslog daemon\n  facility: 'user',       // syslog facility to log to\n  fqdn: os.hostname()     // hostname of the system; logged in syslog header\n})\n\n// Pipe the log agent into the sinks\nlog.pipe(stderr)\nlog.pipe(rotatingFile)\nlog.pipe(syslog)\n\n// Use the log agent\nlog.emergency('this will be logged to stderr and syslog')\nlog.alert('this will be logged to stderr and syslog')\nlog.critical('this will be logged to stderr and syslog')\nlog.error('this will be logged to stderr and rotating file')\nlog.warning('this will be logged to stderr and rotating file')\nlog.notice('this will be logged only to stderr and rotating file')\nlog.info('this will be logged only to stderr and rotating file')\nlog.debug('this will be logged only to stderr')\n```\n\n## agent\n\nThe log agent is a `Readable` object-mode stream with logging/metrics methods attached and is provided by the module as a singleton.\n\nThe log levels are taken from Syslog and include:\n- `emergency`: conditions requiring immediate operator intervention to proceed (e.g. out-of-memory)\n- `alert`: conditions requiring immediate operator intervention (e.g. high cpu usage)\n- `critical`: conditions indicating critical process state (e.g. low disk space)\n- `error`: error conditions\n- `warning`: warning conditions\n- `notice`: normal but significant conditions\n- `info`: informational logging\n- `debug`: debug logging\n\nThe metrics methods include:\n- `counter`: records the count of values\n- `histogram`: records the distribution of values\n\n## sinks\n\nSinks are `Writable` object-mode streams that filter log messages and write them to the specified destination. The sinks provided with this module include:\n\n### `ConsoleSink`\n\nThe console sink writes JSON-serialized logs to the process' `stderr` stream.\n\n### `RotatingFileSink`\n\nThe rotating file sink writes JSON-serialized logs to a file that is rotated every 24 hours. The timestamp from the log message is used to identify when files need to be rotated.\n\n### `SyslogSink`\n\nThe syslog sink writes JSON-serialized logs to the specified syslog server. Since the messages are in JSON format, the syslog server MUST use the [Common Event Expression](https://cee.mitre.org) module.\n","readmeFilename":"README.md"}