{"id":18552465,"url":"https://github.com/andrejewski/console-hook","last_synced_at":"2025-06-18T11:38:17.891Z","repository":{"id":57206096,"uuid":"64665782","full_name":"andrejewski/console-hook","owner":"andrejewski","description":"Hook into the console","archived":false,"fork":false,"pushed_at":"2016-09-23T21:24:25.000Z","size":6,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-13T21:51:39.547Z","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":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrejewski.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":"2016-08-01T12:41:52.000Z","updated_at":"2023-04-19T11:35:30.000Z","dependencies_parsed_at":"2022-09-18T06:55:45.067Z","dependency_job_id":null,"html_url":"https://github.com/andrejewski/console-hook","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andrejewski/console-hook","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fconsole-hook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fconsole-hook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fconsole-hook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fconsole-hook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrejewski","download_url":"https://codeload.github.com/andrejewski/console-hook/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrejewski%2Fconsole-hook/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259927743,"owners_count":22933285,"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":[],"created_at":"2024-11-06T21:14:18.665Z","updated_at":"2025-06-18T11:38:12.870Z","avatar_url":"https://github.com/andrejewski.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Console Hook\n\nHook into the `console` for transparent log recording in production and log capture for testing.\n\n```sh\nnpm install console-hook\n```\n\nWorks in the browser too, just grab `console-hook/index.js`.\n\n## Examples\n\n### Intercept all `console` method calls\n\n```js\nvar Hook = require('console-hook');\nvar myHook = Hook().attach((method, args) =\u003e {\n  // method is the console[method] string\n  // args is the arguments object passed to console[method]\n});\n\n// okay, we're done playing with the console stuffs\nmyHook.detach();\n```\n\n### Intercept all `console` method calls and don't call `console`\n\n```js\nvar Hook = require('console-hook');\nvar silence = true; // could be `isProduction`\nvar myHook = Hook(console, silence).attach((method, args) =\u003e {\n  // method is the console[method] string\n  // args is the arguments object passed to console[method]\n});\n\n// okay, we're done playing with the console stuffs\nmyHook.detach();\n```\n\n### Intercept only `console.error` calls\n\n```js\nvar Hook = require('console-hook');\nvar myHook = Hook().attach('error', (method, args) =\u003e {\n  // method is the console[method] string, always \"error\"\n  // args is the arguments object passed to console[method]\n});\n\n// okay, we're done playing with the console stuffs\nmyHook.detach();\n```\n\n### Use another `console`-like Logger\n\n```js\n// if you have an Ember app and already use Ember.Logger\nvar Hook = require('console-hook');\nvar myHook = Hook(Ember.Logger).attach((method, args) =\u003e {\n  // method is the console[method] string\n  // args is the arguments object passed to console[method]\n});\n\n// okay, we're done playing with the console stuffs\nmyHook.detach();\n```\n\n## Contributing\n\nContributions are incredibly welcome as long as they are standardly applicable\nand pass the tests (or break bad ones). Tests are written in Mocha and\nassertions are done with the Node.js core `assert` module.\n\n```bash\n# running tests\nnpm run test\n```\n\nFollow me on [Twitter](https://twitter.com/compooter) for updates or just for\nthe lolz and please check out my other [repositories](https://github.com/andrejewski)\n if I have earned it. I thank you for reading.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrejewski%2Fconsole-hook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrejewski%2Fconsole-hook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrejewski%2Fconsole-hook/lists"}