{"id":21406918,"url":"https://github.com/francosion042/console-watcher","last_synced_at":"2025-08-25T15:03:05.894Z","repository":{"id":201025121,"uuid":"705880643","full_name":"francosion042/console-watcher","owner":"francosion042","description":"console-watcher is a utility library that provides extended logging capabilities for NodeJs applications. It overrides the native console methods, allowing developers to customize how logs are handled. Logs can be saved to a file, or synced to a dedicated server while retaining the ability to display or hide them in the console for security reasons","archived":false,"fork":false,"pushed_at":"2023-11-16T12:16:38.000Z","size":262,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-28T09:20:55.890Z","etag":null,"topics":["hacktoberfest","javascript","logging","nodejs","npm","server"],"latest_commit_sha":null,"homepage":"","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/francosion042.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":"2023-10-16T21:55:10.000Z","updated_at":"2023-10-22T18:22:03.000Z","dependencies_parsed_at":"2024-11-22T16:43:54.209Z","dependency_job_id":"f3376766-7234-494a-af94-f9aad915522d","html_url":"https://github.com/francosion042/console-watcher","commit_stats":null,"previous_names":["francosion042/console-watcher"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/francosion042/console-watcher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francosion042%2Fconsole-watcher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francosion042%2Fconsole-watcher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francosion042%2Fconsole-watcher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francosion042%2Fconsole-watcher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/francosion042","download_url":"https://codeload.github.com/francosion042/console-watcher/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francosion042%2Fconsole-watcher/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265227900,"owners_count":23731060,"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":["hacktoberfest","javascript","logging","nodejs","npm","server"],"created_at":"2024-11-22T16:43:39.279Z","updated_at":"2025-07-14T00:32:51.685Z","avatar_url":"https://github.com/francosion042.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# console-watcher\n\n\u003c!-- markdownlint-disable MD029 --\u003e\n\u003c!-- markdownlint-disable MD033 --\u003e\n\u003cdiv align=\"center\"\u003e\n\n[![Publish Package to npmjs](https://github.com/francosion042/console-watcher/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/francosion042/console-watcher/actions/workflows/npm-publish.yml) [![npm version](https://img.shields.io/npm/v/console-watcher.svg?style=flat-square)](https://www.npmjs.org/package/console-watcher) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](http://makeapullrequest.com) [![Downloads](https://img.shields.io/npm/dm/console-watcher.svg)](https://www.npmjs.com/package/console-watcher)\n\n## \u003c/div\u003e\n\n`console-watcher` is a utility library that provides extended logging capabilities for Node.js applications. It overrides the native console methods, allowing developers to customize how logs are handled. Logs can be saved to a file, or even synced to a dedicated cloud while retaining the ability to display or hide them in the console for security reasons.\n\n## Features\n\n- Override native console logging methods (`console.log`, `console.info`, `console.error`).\n- Configurable behavior to print in console or save to a file.\n- Supports both JSON and non-JSON file types for logs saving.\n- Encrypt and sync logs to a dedicated cloud for better visualization and management.\n- Register your custom error handling function which will be called whenever an error occurs within the library.\n\n## Installation\n\n```bash\nnpm install console-watcher\n```\n\n## Usage\n\nTo use `console-watcher`, first import the class in your app's entry file and create a new instance.\n\n```typescript\nimport ConsoleWatcher from 'console-watcher'\n\nconst watcher = new ConsoleWatcher(config)\n```\n\n## Configuration\n\nWhen initializing `console-watcher`, you can pass in a configuration object with the following properties:\n\n- `printInConsole`: Determines if the log should be displayed in the console. Default is `true`.\n- `saveToFile`: Determines if the log should be saved to a file. Default is `true`.\n- `logFilePath`: Specifies the path of the log file. The utility checks for the file type to determine if it's JSON or non-JSON. Default file path is `console-watcher.log`.\n\n```typescript\nconst config = {\n  printInConsole: true,\n  saveToFile: true,\n  logFilePath: 'consoleWatcher.json',\n}\n```\n\n## Global Error Handling\n\nConsole Watcher supports a global error handler. You can register your custom error handling function which will be called whenever an error occurs within the library.\n\n```typescript\nwatcher.registerGlobalErrorHandler((error) =\u003e {\n  console.error(\n    'An error occurred in Console Watcher:',\n    error.message ?? error?.response?.statusText ?? 'Unknown'\n  )\n})\n```\n\nBy registering a global error handler, you have the flexibility to handle errors in a way that best suits your application, whether it’s logging, alerting the user, or other custom behaviors.\n\n## Syncing to ConsoleWatcher Cloud\n\nConsoleWatcher provides the flexibility to sync your logs to a dedicated cloud, either manually or at regular intervals. This feature enhances log visualization and management.\n\nTo manually sync logs:\n\n```typescript\nwatcher.syncToConsoleWatcherCloud({\n  apiKey: 'YOUR_API_KEY',\n  applicationKey: 'YOUR_APPLICATION_KEY',\n  encryptionKey: 'YOUR_ENCRYPTION_KEY',\n})\n```\n\nFor automated intervals, you can set up a routine using JavaScript's `setInterval`:\n\n```typescript\nsetInterval(() =\u003e {\n  watcher.syncToConsoleWatcherCloud({\n    apiKey: 'YOUR_API_KEY',\n    applicationKey: 'YOUR_APPLICATION_KEY',\n    encryptionKey: 'YOUR_ENCRYPTION_KEY',\n  })\n}, YOUR_DESIRED_INTERVAL_IN_MILLISECONDS)\n```\n\nReplace `YOUR_DESIRED_INTERVAL_IN_MILLISECONDS` with the frequency you want the sync operation to occur (e.g., `60000` for every minute). Adjust as needed to suit your application's requirements.\n\nSync Configuration:\n\n- `apiKey`: Your dedicated API key for the ConsoleWatcher platform.\n- `applicationKey`: Your application’s unique key on the ConsoleWatcher platform.\n- `encryptionKey`: A private key unique to you. Ensure you keep this key safe and don’t lose it to prevent data loss. This key must be exactly 16 characters in length.\n\nNote: The encryption key is used to encrypt logs before they’re sent to the cloud. This ensures data privacy and security. It’s vital not to lose or change this key to avoid losing already encrypted data.\n\n## Contributing\n\nFirst and foremost, thank you for your interest in contributing to ConsoleWatcher! Open source projects like this thrive because of contributors like you. Here's how you can help:\n\n### Getting Started\n\n1. **Fork the Repository**: Start by forking the console-watcher repository to your own GitHub account.\n\n2. **Clone the Repository**: Once you have forked the repo, clone it to your local machine:\n\n   ```bash\n   git clone https://github.com/YOUR_USERNAME/console-watcher.git\n   ```\n\n3. **Install Dependencies**: After cloning, navigate to the project directory and install the necessary dependencies:\n\n   ```bash\n   cd console-watcher\n   npm install\n   ```\n\n### Making Changes\n\n4. **Create a New Branch**: Always create a new branch for your changes:\n\n   ```bash\n   git checkout -b feature/your-feature-name\n   ```\n\n5. **Make Your Changes**: Implement your feature or bug fix.\n\n6. **Run Tests**: Ensure that your changes do not break any existing functionality. Add new tests if necessary.\n\n7. **Commit Your Changes**: Once you're satisfied with your changes, stage and commit them:\n\n   ```bash\n   git add .\n   git commit -m \"Add some feature or fix some bug\"\n   ```\n\n8. **Push to Your Fork**: Push your changes to your forked repository:\n\n   ```bash\n   git push origin feature/your-feature-name\n   ```\n\n### Submitting a Pull Request\n\n9. **Open a Pull Request**: Navigate to the ConsoleWatcher repository and click on \"Pull Requests\". Click the \"New Pull Request\" button and select your fork and branch.\n\n10. **Describe Your Changes**: In the pull request description, explain your changes, why you made them, and any additional context if necessary.\n\n11. **Wait for Review**: The maintainers will review your pull request, provide feedback, and merge it once it's approved.\n\n### Additional Notes\n\n- **Respect the Code of Conduct**: Please ensure that you follow the project's code of conduct in all interactions.\n\n- **Ask for Help**: If you're stuck or unsure about something, don't hesitate to ask for help. The community is here to assist.\n\n- **Stay Updated**: Make sure to pull the latest changes from the `master` branch before creating a new pull request.\n\nThank you for your contribution! Your efforts help make ConsoleWatcher better for everyone.\n\n## License\n\nMIT\n\n---\n\nThis README provides a basic introduction and guide to using the `console-watcher` utility. Additional sections, such as a more detailed installation guide, examples, and information about dependencies, can be added as required.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancosion042%2Fconsole-watcher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrancosion042%2Fconsole-watcher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancosion042%2Fconsole-watcher/lists"}