{"id":19031,"library":"babel-plugin-captains-log","title":"babel-plugin-captains-log","description":"A Babel plugin (v1.3.2, last updated July 2020, no recent releases) that automatically injects file name, line/column position, and variable name labels into console.log and other console method calls. Unlike manual logging wrappers, it works at the AST level during build time, supports ignore patterns, custom logger names, and selective method targeting. Requires Babel v6, ESM/CJS compatible, used as a development transform to enhance debugging output in bundled code.","status":"maintenance","version":"1.3.2","language":"javascript","source_language":"en","source_url":"https://github.com/kwelch/babel-plugin-captains-log","tags":["javascript","babel","babel-plugin","logging"],"install":[{"cmd":"npm install babel-plugin-captains-log","lang":"bash","label":"npm"},{"cmd":"yarn add babel-plugin-captains-log","lang":"bash","label":"yarn"},{"cmd":"pnpm add babel-plugin-captains-log","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peer dependency for Babel plugin compatibility","package":"@babel/core","optional":false}],"imports":[{"note":"CJS-only package; use require in .babelrc or programmatic Babel config. No ESM wrapper provided.","wrong":"import plugin from 'babel-plugin-captains-log'","symbol":"default","correct":"module.exports = require('babel-plugin-captains-log')"}],"quickstart":{"code":"// .babelrc\n{\n  \"plugins\": [\"babel-plugin-captains-log\"]\n}\n\n// Before transformation\nlet x = 5;\nconsole.log(x);\n\n// After transformation (output during development)\nlet x = 5;\nconsole.log(\"input.js(3:0)\", \"x\", x);\n\n// With options\n{\n  \"plugins\": [\n    [\"babel-plugin-captains-log\", {\n      \"methods\": [\"debug\", \"info\"],\n      \"ignorePatterns\": [\"node_modules\", \"*.spec.js\"],\n      \"loggerName\": \"myLogger\",\n      \"injectVariableName\": true,\n      \"injectFileName\": true\n    }]\n  ]\n}","lang":"javascript","description":"Demonstrates plugin setup in .babelrc, default transformation adding file location and variable name, and all available options."},"warnings":[{"fix":"Use @babel/plugin prefix or consider alternatives for Babel 7, e.g., babel-plugin-transform-console-log or custom build.","message":"Requires Babel v6, not v7+","severity":"breaking","affected_versions":"all"},{"fix":"Disable injectVariableName in production build or use plugin only in development mode.","message":"Plugin mutates console statements globally; logged variable name may show original variable name even after minification if source maps enabled","severity":"gotcha","affected_versions":"all"},{"fix":"Consider actively maintained alternatives like babel-plugin-transform-console-log, or fork the repository.","message":"No updates since July 2020; repository may be unmaintained","severity":"deprecated","affected_versions":">=1.3.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"npm install --save-dev babel-plugin-captains-log","cause":"Plugin not installed or Babel not configured to resolve node_modules","error":"Error: Cannot find module 'babel-plugin-captains-log'"},{"fix":"Ensure Babel presets or plugins (e.g., @babel/preset-env) are configured to transpile the output.","cause":"Plugin transforms code but Babel version does not support the output syntax (e.g., arrow functions in older environments)","error":"SyntaxError: Unexpected token (3:0)"},{"fix":"Upgrade to a Babel 7 compatible plugin or downgrade to Babel 6.","cause":"Using plugin with Babel 7 which has different visitor API","error":"TypeError: Cannot read property 'scope' of undefined"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}