{"id":13764205,"url":"https://github.com/neat-log/neat-log","last_synced_at":"2026-01-14T15:39:25.386Z","repository":{"id":46693948,"uuid":"87225535","full_name":"neat-log/neat-log","owner":"neat-log","description":"a neat cli logger for stateful command line applications","archived":false,"fork":false,"pushed_at":"2021-09-29T17:21:00.000Z","size":170,"stargazers_count":65,"open_issues_count":5,"forks_count":17,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-17T05:00:01.229Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neat-log.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-04T19:14:31.000Z","updated_at":"2025-01-17T03:49:59.000Z","dependencies_parsed_at":"2022-09-12T23:22:32.353Z","dependency_job_id":null,"html_url":"https://github.com/neat-log/neat-log","commit_stats":null,"previous_names":["joehand/neat-log"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/neat-log/neat-log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neat-log%2Fneat-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neat-log%2Fneat-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neat-log%2Fneat-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neat-log%2Fneat-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neat-log","download_url":"https://codeload.github.com/neat-log/neat-log/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neat-log%2Fneat-log/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28424374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T13:30:50.153Z","status":"ssl_error","status_checked_at":"2026-01-14T13:29:08.907Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T16:00:15.914Z","updated_at":"2026-01-14T15:39:25.367Z","avatar_url":"https://github.com/neat-log.png","language":"JavaScript","funding_links":[],"categories":["Output"],"sub_categories":[],"readme":"# neat-log\n\n[![npm][npm-image]][npm-url]\n[![travis][travis-image]][travis-url]\n[![standard][standard-image]][standard-url]\n\nA neat logger for command line tools, inspired by [Choo](https://github.com/yoshuawuyts/choo)! I've heard so much about how awesome front-end javascript has gotten, I wanted to bring some of that magic to command line applications. Used in the [Dat](https://github.com/datproject/dat) command line tool.\n\n* Use easy-to-read strings to create console outputs.\n* Automatically diff template output with existing console (via [diffy](https://github.com/mafintosh/diffy)) (pretty much React for your terminal).\n* Update console output in any order with event based output.\n* Handle command line input via integrated [neat-input](https://github.com/mafintosh/neat-input) on the `input` property ([example](https://github.com/cabal-club/cabal/blob/master/neat-screen.js#L28)).\n* Pretty neat!\n\n### Example\n\nEach neat logger has two components: a `view` and functions that modify state and emit events.\n\n```js\nvar neatLog = require('neat-log')\nvar output = require('neat-log/output')\n\nvar neat = neatLog(view)\nneat.use(countTheSeconds)\n\nfunction view (state) {\n  // This gets printed to the console! Wow. So neat.\n  return output(`\n    Hello World!\n    I've been running for ${state.seconds} second${state.seconds === 1 ? '' : 's'}.\n  `)\n}\n\nfunction countTheSeconds (state, bus) {\n  state.seconds = 0\n  setInterval(function () {\n    state.seconds++\n    bus.emit('render')\n  }, 1000)\n  bus.emit('render')\n}\n```\n\nThis example will print to the console: \n\n```\nHello world!\nI've been running for 0 seconds.\n```\n\nAnd update every second!\n\nMore examples:\n\n* [dat](https://github.com/datproject/dat) - full command line application with multiple views, components, etc.\n* [cabal](https://github.com/cabal-club/cabal) - p2p chat application.\n* [count-files](https://github.com/joehand/count-files) - simple example with a single view and use function.\n* [basic examples](/examples)\n\n### Components\n\nNeat-log works great with components, just like Choo!\n\n* [Task lister](https://github.com/joehand/neat-tasks): task runner with pretty output. Used in [dat-doctor](https://github.com/datproject/dat-doctor).\n* [Spinner](https://github.com/joehand/neat-spinner): pretty spinner for the cli.\n* [Text Blit](https://github.com/noffle/txt-blit): Draw lines of text onto other lines of text.\n\nYou can use string-based components too! Check out [diff components](https://github.com/mafintosh/diffy#components) for more.\n\n## Install\n\n```\nnpm install neat-log\n```\n\n## API\n\nHeavily inspired by Choo! If you get confused here, check docs there because they are much nicer =).\n\n### `var neat = neatLog(view(state), [opts])`\n\n* `views` is a single function or array of functions that return string(s) to output to the console. `views` are passed the `state` as the first argument.\n* `opts.logspeed` (default 250ms) - throttles how often output is rendered.\n* `opts.quiet` - shhhh.... do not print anything\n* `opts.state` - pass in initial state\n\n### `neat.use(callback(state, bus))`\n\nUse a `function (state, bus)` to change state and emit events via the bus. You can call `bus.emit()` to emit a new event and `bus.on()` to listen. Emitter is an instance of [nanobus](https://github.com/yoshuawuyts/nanobus/).\n\n`bus` also has some special functions/events:\n\n#### `bus.render()`\n\nCause an immediate render (normally it'd be throttled). This is helpful to do before exiting.\n\n#### `bus.on('exit')`\n\nHandle exit from `process.on('SIGINT')`. Useful for rendering exit messages, etc. If no handler is provided, process will exit.\n\n### `neat.render()`\n\nFor an immediate render. Helpful outside of a use function.\n\n### `var output = require('neat-log/output')`\n\nGet a function to make your template literals nicer. Removes spaces and stuff™.\n\n# Combines well with..\n\n- [txt-blit](https://github.com/noffle/txt-blit)\n\n# Licensing\n\nThis package is free to use for noncommercial purposes and for commercial purposes during a trial period under the terms of the [Prosperity Public License](./LICENSE).\n\nLicenses for long-term commercial use are available via [licensezero.com](https://licensezero.com).\n\n[![licensezero.com pricing](https://licensezero.com/projects/0153a099-6acd-4023-8a96-9d81d9969a58/badge.svg)](https://licensezero.com/projects/0153a099-6acd-4023-8a96-9d81d9969a58)\n\n\n[npm-image]: https://img.shields.io/npm/v/neat-log.svg?style=flat-square\n[npm-url]: https://www.npmjs.com/package/neat-log\n[travis-image]: https://img.shields.io/travis/joehand/neat-log.svg?style=flat-square\n[travis-url]: https://travis-ci.org/joehand/neat-log\n[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square\n[standard-url]: http://npm.im/standard\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneat-log%2Fneat-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneat-log%2Fneat-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneat-log%2Fneat-log/lists"}