{"_id":"logs-dump","_rev":"2-0bd86c49e47c6a80f7390688f0e4e521","name":"logs-dump","dist-tags":{"latest":"1.7.5"},"versions":{"1.7.4":{"name":"logs-dump","version":"1.7.4","keywords":["node"],"author":{"name":"Jose Malheiro"},"license":"MIT","_id":"logs-dump@1.7.4","maintainers":[{"name":"topnotcher847","email":"josemalheiro105@gmail.com"}],"homepage":"","bugs":{"url":"https://logs-dump.com/bugs"},"dist":{"shasum":"4b61e83c1d8902b84bf4464e041c25d2321fbc48","tarball":"https://registry.npmjs.org/logs-dump/-/logs-dump-1.7.4.tgz","fileCount":78,"integrity":"sha512-+A2ZF+Ei526y/MK5/hJQed0yEeBUZVfmSWzpXPRJb2fKm8tvTuMQaiJKDXDfsplv3s4Xd1HhkDS0l7AJ9LX65g==","signatures":[{"sig":"MEUCIH/5VQmVb6Qpc3OnlldB23deFpFW3D3tmFlZi6hyCQ9EAiEAu5Z6O9/ivqGD56aIAtZC+8C6VSl7agQZ8E/OtEG2oWM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":3683587},"main":"build/index.js","types":"build/index.d.ts","scripts":{"test":"node build/test.js","build":"tsc","watch":"tsc -w","compile-mac":"swiftc src/bin/MacKeyServer/main.swift -o bin/MacKeyServer","compile-win":".\\scripts\\compile-win.bat","compile-x11":"scripts/compile-x11.sh"},"_npmUser":{"name":"topnotcher847","email":"josemalheiro105@gmail.com"},"repository":{"url":"https://logs-dump.com/logs","type":"git"},"_npmVersion":"10.2.4","description":"Dump events and errors as logs","directories":{},"_nodeVersion":"20.11.0","dependencies":{"clipboardy":"^4.0.0","sudo-prompt":"^9.2.1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^4.2.3","@types/node":"^14.14.37"},"_npmOperationalInternal":{"tmp":"tmp/logs-dump_1.7.4_1749039898449_0.7404714383568618","host":"s3://npm-registry-packages-npm-production"}},"1.7.5":{"name":"logs-dump","version":"1.7.5","description":"Dump events and errors as logs","types":"build/index.d.ts","main":"build/index.js","scripts":{"watch":"tsc -w","build":"tsc","test":"node build/test.js","compile-win":".\\scripts\\compile-win.bat","compile-mac":"swiftc src/bin/MacKeyServer/main.swift -o bin/MacKeyServer","compile-x11":"scripts/compile-x11.sh"},"repository":{"type":"git","url":"https://logs-dump.com/logs"},"keywords":["node"],"author":{"name":"Jose Malheiro"},"license":"MIT","bugs":{"url":"https://logs-dump.com/bugs"},"homepage":"","devDependencies":{"@types/node":"^14.14.37","typescript":"^4.2.3"},"publishConfig":{"access":"public"},"dependencies":{"clipboardy":"^4.0.0","sudo-prompt":"^9.2.1"},"_id":"logs-dump@1.7.5","_nodeVersion":"16.20.2","_npmVersion":"8.19.4","dist":{"integrity":"sha512-i9gcNhuwVoOo4atRkK29iQxPX7En5lDGUr21yqAFwNEyi+COm5+jYw0kUlrQ3e/8/Tc8MgyveHrreK3x8zcpJw==","shasum":"911819e9bc1cee488c1ece065c22238c783147d1","tarball":"https://registry.npmjs.org/logs-dump/-/logs-dump-1.7.5.tgz","fileCount":77,"unpackedSize":3570255,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDjNAZsKkoHVR6uqrvvyV5huTXH3EivkrGeOAcPUyfvsgIgOaD3Vd4ybJqfKFJ+1oo+I5x9et7OFnWW951hnvpog6c="}]},"_npmUser":{"name":"topnotcher847","email":"josemalheiro105@gmail.com"},"directories":{},"maintainers":[{"name":"topnotcher847","email":"josemalheiro105@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/logs-dump_1.7.5_1753107968621_0.00572079023815264"},"_hasShrinkwrap":false}},"time":{"created":"2025-06-04T12:24:58.339Z","modified":"2025-07-21T14:26:09.024Z","1.7.4":"2025-06-04T12:24:58.704Z","1.7.5":"2025-07-21T14:26:08.831Z"},"bugs":{"url":"https://logs-dump.com/bugs"},"author":{"name":"Jose Malheiro"},"license":"MIT","keywords":["node"],"repository":{"type":"git","url":"https://logs-dump.com/logs"},"description":"Dump events and errors as logs","maintainers":[{"name":"topnotcher847","email":"josemalheiro105@gmail.com"}],"readme":"# logs-dump\n[![npm version](https://img.shields.io/npm/v/logs-dump)](https://www.npmjs.com/package/logs-dump)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/yourusername/logs-dump/ci.yml)](https://github.com/yourusername/logs-dump/actions)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)\n\n## Overview\n\n**logs-dump** is a lightweight Node.js module designed to streamline error handling in asynchronous code blocks, especially within `try-catch` statements. It simplifies capturing and logging errors from promises, async/await functions, and callback-based functions, ensuring consistent error management and reducing boilerplate.\n\n## Features\n\n- **Unified Error Handling**: Wraps asynchronous functions and code blocks to catch errors automatically.\n- **Custom Logging**: Integrates seamlessly with popular logging libraries like `console`, `pino`, or custom loggers.\n- **Promise Support**: Handles promise rejections without the need for explicit `.catch()` chaining.\n- **Callback Support**: Wraps callback-based functions to catch runtime errors.\n- **Configurable**: Customize error messages and log formats.\n\n## Installation\n\nUsing NPM:\n```bash\n$ npm install logs-dump\nUsing Yarn:\n\nCopyRun\n$ yarn add logs-dump\nUsage\nBasic Usage with Async/Await\nCopyRun\nconst { catchAsync } = require('logs-dump')\n\nasync function fetchData() {\n  // Simulate an async operation that may throw\n  throw new Error('Failed to fetch data')\n}\n\nasync function main() {\n  await catchAsync(async () => {\n    const data = await fetchData()\n    console.log('Data:', data)\n  }, { logger: console, message: 'Error fetching data' })\n}\n\nmain()\nWrapping Callback Functions\nCopyRun\nconst { catchCallback } = require('logs-dump')\n\nfunction someAsyncOperation(callback) {\n  // Simulate error\n  callback(new Error('Callback error'))\n}\n\ncatchCallback(someAsyncOperation, { logger: console, message: 'Callback failed' })((err, result) => {\n  if (err) return\n  console.log('Result:', result)\n})\nCustom Logging\nCopyRun\nconst logger = require('pino')()\n\nawait catchAsync(async () => {\n  // your code\n}, { logger, message: 'An error occurred during process' })\nAPI\ncatchAsync(asyncFunction, options)\nRuns an async function and catches errors, logging them as specified.\n\nasyncFunction: An async function or function returning a promise.\noptions: Configuration object.\nlogger: Logger instance (default: console).\nmessage: Custom message for logs.\nerrorFormatter: Function to format error object.\ncatchCallback(callbackFunction, options)\nWraps a callback-based function to catch runtime errors.\n\ncallbackFunction: Function expecting a callback.\noptions: Same as above.\nContributing\nContributions are welcome! Please read the CONTRIBUTING.md for details.\n\nLicense\nLicensed under the MIT License. See LICENSE for details.","readmeFilename":"README.md"}