{"id":19164,"library":"babel-plugin-shotgun-logs","title":"babel-plugin-shotgun-logs","description":"A Babel plugin for automatically injecting detailed function entry and exit log statements into JavaScript code. Version 0.0.5 is the latest. The plugin instruments every function call with colored entry/exit logs including argument values, return values, and nested call indentation. It integrates with log management tools and supports options for function blacklisting, blackout lists, external JSON storage, and time profiling. Differentiates from simple logging libraries by being compile-time, thus requiring no runtime changes and providing full call tree visibility.","status":"active","version":"0.0.5","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install babel-plugin-shotgun-logs","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-shotgun-logs","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-shotgun-logs","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM default import works; CJS require yields the plugin function directly.","wrong":"const plugin = require('babel-plugin-shotgun-logs').default","symbol":"default","correct":"import plugin from 'babel-plugin-shotgun-logs'"},{"note":"Do not wrap with extra object. In .babelrc or babel.config.js, just use the string name or an array tuple.","wrong":"plugins: [{ 'babel-plugin-shotgun-logs': {} }]","symbol":"(plugin is default export)","correct":"plugins: ['babel-plugin-shotgun-logs']"}],"quickstart":{"code":"// Install: npm install babel-plugin-shotgun-logs --save-dev\n// In .babelrc:\n{\n  \"plugins\": [\n    [\"babel-plugin-shotgun-logs\", {\n      \"isTerminal\": true,\n      \"entryLogShowFullArgs\": true,\n      \"exitLogReturnOutputInline\": true\n    }]\n  ]\n}\n\n// Example instrumented code (before/after):\n// Before:\nfunction add(a, b) {\n  return a + b;\n}\n// After (output to log):\n// 🟢  add( a: 2, b: 3 ) {\"a\":2,\"b\":3}\n// 🔴  add() ⇒ 5 {\"return\":5}","lang":"javascript","description":"Shows installation, Babel configuration, and an example of instrumented function entry/exit logs."},"warnings":[{"fix":"Configure Babel to exclude node_modules by default or use include/exclude patterns.","message":"Plugin modifies all functions, including third-party code if not scoped. Use withIncludes/withExcludes to restrict.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Set entryLogShowFullArgs to false or use storeJSONexternally with a reasonable sizeThreshold.","message":"Logging large arguments with entryLogShowFullArgs can produce enormous log files, potentially filling disk.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use @babel/preset-typescript to strip types before this plugin runs, or use babel-plugin-ts2js.","message":"The plugin does not work with TypeScript out-of-the-box; it only transforms JavaScript.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Ensure AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set properly and restricted to the specific bucket.","message":"S3 storage (storeJSONexternally.location: 's3') requires AWS credentials via environment variables, which may be a security risk.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Add @babel/plugin-transform-runtime and @babel/runtime to your Babel config.","cause":"Babel transforms async functions but does not polyfill regeneratorRuntime. This plugin does not add the polyfill.","error":"ReferenceError: regeneratorRuntime is not defined"},{"fix":"Set entryLogShowFullArgs to false or ensure all function arguments are defined.","cause":"The plugin tries to log arguments that are undefined, causing a crash when calling .toString.","error":"TypeError: Cannot read property 'toString' of undefined"},{"fix":"Install aws-sdk: npm install aws-sdk --save-dev","cause":"storeJSONexternally with location 's3' requires aws-sdk as a peer dependency, which is not installed automatically.","error":"Module not found: Can't resolve 'aws-sdk'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}