{"id":26058921,"url":"https://github.com/zackiles/console-monkey-patch","last_synced_at":"2026-01-28T19:34:18.498Z","repository":{"id":259368694,"uuid":"877724932","full_name":"zackiles/console-monkey-patch","owner":"zackiles","description":"Control where all console methods write to, avoiding writing to the process stdout and stderr.","archived":false,"fork":false,"pushed_at":"2024-10-24T07:21:21.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-22T03:28:11.093Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/zackiles.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-24T06:17:48.000Z","updated_at":"2024-10-24T07:21:25.000Z","dependencies_parsed_at":"2024-10-24T22:32:34.374Z","dependency_job_id":"bbcb6d4e-202c-4047-acb9-3d83e2982fa9","html_url":"https://github.com/zackiles/console-monkey-patch","commit_stats":null,"previous_names":["zackiles/console-monkey-patch"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zackiles/console-monkey-patch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackiles%2Fconsole-monkey-patch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackiles%2Fconsole-monkey-patch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackiles%2Fconsole-monkey-patch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackiles%2Fconsole-monkey-patch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zackiles","download_url":"https://codeload.github.com/zackiles/console-monkey-patch/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zackiles%2Fconsole-monkey-patch/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28850334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T15:15:36.453Z","status":"ssl_error","status_checked_at":"2026-01-28T15:15:13.020Z","response_time":57,"last_error":"SSL_read: 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":"2025-03-08T12:40:59.243Z","updated_at":"2026-01-28T19:34:18.482Z","avatar_url":"https://github.com/zackiles.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Console Monkey Patch\n\n**[Overview]**\n\nA versatile logging utility for Node.js that lets you intercept, extend, or replace console methods for custom logging workflows.\n\n1. **Bring Your Own Logger**: Seamlessly monkey-patch popular logging libraries (e.g., native `console`, `winston`, `pino`) to redirect their outputs to in-memory logs (`this.context.stdout`/`stderr`). Perfect for environments like sandboxes where you need to capture and control all logging.\n\n2. **Hook Mode**: Enable hook mode to chain pre-processing functions before passing messages to your existing logging library. This allows you to extend functionality without replacing your original methods.\n\n3. **In-Memory Logger**: Don't have a logging library? No problem. Get a console-like interface with in-memory logging, leveraging `this.context.stdout` and `stderr` to store logs without printing them.\n\nIdeal for sandboxed environments, custom log pipelines, or capturing logs without terminal output.\n\n---\n\n**[Calling Conventions]**\n\n| Name                                    | Function    | Calling Signature                           | Can't Exist                             | hookMode | Local Log | Patch Type               |\n|-----------------------------------------|-------------|---------------------------------------------|-----------------------------------------|----------|-----------|--------------------------|\n| Instantiation with context              | constructor | (context)                                   | No consoleInstanceClass                | false    | Yes       | Full Replace             |\n| Instantiation with console              | constructor | (consoleInstanceClass, hookMode?)           | No context                             | optional | No        | Full Replace / Chained Hook (based on hookMode) |\n| Instantiation with context and console  | constructor | (context, consoleInstanceClass, hookMode?)  | N/A                                    | optional | Yes       | Full Replace / Chained Hook (based on hookMode) |\n| Patch with context                      | patch       | (context, consoleInstanceClass?, hookMode?) | No patching without context            | optional | Yes       | Full Replace             |\n| Patch with console                      | patch       | (consoleInstanceClass, hookMode?)           | No context                             | optional | No        | Full Replace / Chained Hook (based on hookMode) |\n\n---\n\n**[Rules to explore]**\n\n| Rule                                                                                                           | Related To                                           |\n|----------------------------------------------------------------------------------------------------------------|------------------------------------------------------|\n| Local logging to `this.context.stderr` and `this.context.stdout` require a context to be passed so they can log to the class locally | Instantiation with context, Instantiation with context and console, Patch with context |\n| If local logging is not needed (i.e., when the caller provides an external logging mechanism via a console instance or context functions), `this.context.stdout` and `this.context.stderr` should be explicitly set to `null` to avoid unnecessary duplication of logs in memory | Instantiation with console, Instantiation with context and console, Patch with console |\n| If both a context and an external logging library are provided but local logging is not required, `this.context.stdout` and `stderr` should be explicitly set to `null` to avoid log duplication | Instantiation with context and console, Patch with console |\n| When no external logging library is provided, the library should default to in-memory logging via `this.context.stdout` and `stderr`, ensuring both are initialized as non-null strings | Instantiation with context, Patch with context |\n| When hook mode is enabled, local logging (`this.context.stdout` and `stderr`) should be completely bypassed, with all logs processed only by the chained external logging method | Instantiation with console, Instantiation with context and console, Patch with console |\n| Ensure that in paths where external logging is used, no interaction occurs with `this.context.stdout` or `stderr` unless both context and external logging are required | Instantiation with console, Patch with console |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzackiles%2Fconsole-monkey-patch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzackiles%2Fconsole-monkey-patch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzackiles%2Fconsole-monkey-patch/lists"}