{"id":13447088,"url":"https://github.com/lesander/console.history","last_synced_at":"2025-12-24T22:36:11.499Z","repository":{"id":71188883,"uuid":"67145055","full_name":"lesander/console.history","owner":"lesander","description":":scroll: Store all javascript console logs in console.history","archived":false,"fork":false,"pushed_at":"2020-06-28T16:21:46.000Z","size":51,"stargazers_count":38,"open_issues_count":2,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-14T03:43:13.876Z","etag":null,"topics":["console","history","history-array","javascript","logging","node","npm-package"],"latest_commit_sha":null,"homepage":"https://git.io/console","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lesander.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2016-09-01T15:47:33.000Z","updated_at":"2024-11-09T18:48:50.000Z","dependencies_parsed_at":"2023-06-01T13:15:49.499Z","dependency_job_id":null,"html_url":"https://github.com/lesander/console.history","commit_stats":null,"previous_names":["lesander/console-history"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesander%2Fconsole.history","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesander%2Fconsole.history/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesander%2Fconsole.history/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lesander%2Fconsole.history/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lesander","download_url":"https://codeload.github.com/lesander/console.history/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244838032,"owners_count":20518770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["console","history","history-array","javascript","logging","node","npm-package"],"created_at":"2024-07-31T05:01:07.822Z","updated_at":"2025-12-24T22:36:11.437Z","avatar_url":"https://github.com/lesander.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# console.history\n[![npm](https://img.shields.io/npm/v/console.history.svg)]()\n[![GitHub release](https://img.shields.io/github/release/lesander/console.history.svg?maxAge=2592000)]()\n[![npm](https://img.shields.io/npm/dt/console.history.svg)]()\n[![Code Climate](https://codeclimate.com/github/lesander/console.history/badges/gpa.svg)](https://codeclimate.com/github/lesander/console.history)\n[![BCH compliancy](https://bettercodehub.com/edge/badge/lesander/console.history)](https://bettercodehub.com)\n[![Build Status](https://travis-ci.org/lesander/console.history.svg?branch=master)](https://travis-ci.org/lesander/console.history)\n\n\nA very small library to store all console logs in `console.history`.\n\n### Usage\nInclude `console-history.js` or `console-history.min.js` in your page or script before any console function gets called. All calls to `console.log`, `console.info`, `console.warn`, `console.error` and `console.debug` will be intercepted and stored after doing so. *Including every parameter passed to those functions.*\n\n### Getting Started\nThis library works in almost all browsers and on any NodeJS server.\n\n#### Browser\nYou can [download the latest release](https://github.com/lesander/console.history/releases/latest) on GitHub, or use jsDelivr's CDN to get the latest version directly in your browser:\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/gh/lesander/console.history@v1.5.1/console-history.min.js\"\u003e\u003c/script\u003e\n```\nSee an example entry to the history array below. This example is from the [`test/test.js`](test/test.js) file.\n```json\n{\n  \"type\": \"warn\",\n  \"timestamp\": \"Thu, 01 Sep 2016 15:38:28 GMT\",\n  \"arguments\": {\n    \"0\": \"Something went wrong, but we're okay!\"\n  },\n  \"stack\": {\n    \"0\": \"at inner (http://localhost:1337/test/test.js:6:11)\",\n    \"1\": \"at outer (http://localhost:1337/test/test.js:2:3)\",\n    \"2\": \"at http://localhost:1337/test/test.js:9:1\"\n  }\n}\n```\n\n#### Server (NodeJS)\nFetch the latest version of `console.history`:\n```shell\nnpm install console.history\n```\n```js\nrequire('console.history')\nconsole.log('Hello World!')\n```\nAt this point, the `console.history` array is populated with one entry:\n```js\n[\n  {\n    type: 'log',\n    timestamp: 'Thu, 16 Mar 2017 17:24:25 GMT',\n    arguments: { '0': 'Hello World!' },\n    stack: [\n      'at Console.console._intercept (/.../console.history/test/node.js:4:11)',\n      'at Object.\u003canonymous\u003e (/.../console.history/test/node.js:6:9)',\n      'at Module._compile (module.js:571:32)',\n      'at Object.Module._extensions..js (module.js:580:10)',\n      'at Module.load (module.js:488:32)',\n      'at tryModuleLoad (module.js:447:12)',\n      'at Function.Module._load (module.js:439:3)',\n      'at Module.runMain (module.js:605:10)'\n    ]\n  }\n]\n```\n\n#### Intercepting the log function\nYou can add your own middleware to `console.history` with the function `console._intercept(type, args)`. This can prove useful when you need to access a new log entry before or after it gets logged and added to the history array. See an example below.\n\n```js\nconsole._intercept = function (type, args) {\n\n  if (type === 'error') {\n    // send the error to your server or do something else..\n  }\n\n  // pass the log intent to the collector.\n  console._collect(type, args)\n}\n\n```\n\n#### Limitations\n\nEvery saved console log is stored locally in the array `console.history`. A page reload will erase all history, as the array is not permanently stored. You could use `localStorage` or `sessionStorage` for that.\n\n### How it works\nThis script is basically a man-in-the-middle for all `console[log/info/warn/error/debug]` functions. Every call gets intercepted, printed and added to the history array.\n\n![](test/diagram.png)\n\nThe code is not that hard to understand, see [`console-history.js`](/console-history.js) with in-line comments explaining the code.\n\n### Contributing\nIf you'd like to contribute to console.history, or file a bug or feature request, please head over to the issue tracker or open a pull request.\n\nTesting browser-side is as easy as running [`jekyll serve`](https://jekyllrb.com) in the project's directory, navigating to `localhost:4000/test` in your browser and opening [DevTools](https://developer.chrome.com/devtools).\n```shell\ngit clone https://github.com/lesander/console.history.git\ncd console.history\njekyll serve\n```\n\n### License\nThis software is open-sourced under the MIT License ([see the LICENSE file for the full license](/LICENSE)). So within some limits, you can do with the code whatever you want. However, if you like and/or want to re-use it, I'd really appreciate a reference to this project page.\n\nThe software is provided as is. It might work as expected - or not.\nJust don't blame me.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flesander%2Fconsole.history","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flesander%2Fconsole.history","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flesander%2Fconsole.history/lists"}