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.
npm install babel-plugin-captains-logVerified import paths — ran on the pinned version, not inferred.
Demonstrates plugin setup in .babelrc, default transformation adding file location and variable name, and all available options.
Use @babel/plugin prefix or consider alternatives for Babel 7, e.g., babel-plugin-transform-console-log or custom build.
Disable injectVariableName in production build or use plugin only in development mode.
Consider actively maintained alternatives like babel-plugin-transform-console-log, or fork the repository.
npm install --save-dev babel-plugin-captains-log
Ensure Babel presets or plugins (e.g., @babel/preset-env) are configured to transpile the output.
Upgrade to a Babel 7 compatible plugin or downgrade to Babel 6.