# babel-plugin-logfunctionname

> A babel plugin to insert a log in function to show the function name

Latest version **0.0.3** (published 2019-10-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install babel-plugin-logfunctionname
pnpm add babel-plugin-logfunctionname
yarn add babel-plugin-logfunctionname
bun add babel-plugin-logfunctionname
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2019-10-28 |
| First published | 2019-10-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | sz-p |
| Maintainers | psz |
| Keywords | node, babel-plugin, log, function, name |

## Links

- npm: https://www.npmjs.com/package/babel-plugin-logfunctionname
- Repository: https://github.com/sz-p/babel-plugin-logfunctionname
- Issues: https://github.com/sz-p/babel-plugin-logfunctionname/issues
- npm.io page: https://npm.io/package/babel-plugin-logfunctionname

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 0.0.3 (latest) — 2019-10-28
- 0.0.2 — 2019-10-26
- 0.0.1 — 2019-10-22

## README

# babel-plugin-logfunctionname
A babel plugin to insert a log in function to show the function name

if you join in a large project but with no document, this plugin maybe could help you;

## In
```javascript
const functionName = function () {

}
function functionHere() {

}
const arrowFunction = () => {

}
class ClassFunction {
  constructor(name) {
    this.name = name;
  }
  seyHello() {
    console.log(`hello ${this.name}`)
  }
}
let classFunctionItem = new ClassFunction('sz-p')

functionName();
functionHere();
arrowFunction();
classFunctionItem.seyHello();
```
## out
```javascript
"use strict";

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }

function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }

var functionName = function functionName() {
  console.log("function_working:functionName");
};

function functionHere() {
  console.log("function_working:functionHere");
}

var arrowFunction = function arrowFunction() {
  console.log("function_working:arrowFunction");
};

var ClassFunction =
/*#__PURE__*/
function () {
  function ClassFunction(name) {
    console.log("function_working:ClassFunction");

    _classCallCheck(this, ClassFunction);

    this.name = name;
  }

  _createClass(ClassFunction, [{
    key: "seyHello",
    value: function seyHello() {
      console.log("function_working:seyHello");
      console.log("hello ".concat(this.name));
    }
  }]);

  return ClassFunction;
}();

var classFunctionItem = new ClassFunction('sz-p');
functionName();
functionHere();
arrowFunction();
classFunctionItem.seyHello();
```
## Installation
```sh
$ yarn add babel-plugin-logfunctionname -D
```
## Usage

### Via `.babelrc` (Recommended)

**.babelrc**

```json
{
  "plugins": ["babel-plugin-logfunctionname"]
}
```

### Via CLI

```sh
$ babel --plugins babel-plugin-logfunctionname script.js
```

### Via Node API

```javascript
require('babel-core').transform('code', {
  plugins: ['babel-plugin-logfunctionname']
});
```

## Options

|Key|Type|Description|Example|
|:-:|:-:|:-:|:-:|
|enable|boolean|enable or disable plugin|`false`|
|functionWorkingHint|string|The string before functionName|`function_working:`|
|excludeFunctionsName|array|exclude functions by function name|`['doNotLogThis', /^excludeByRegExp/]`|
|excludeFilesName|array|exclude functions by file name|`['subCode', /node_modules/]`|

## test
```sh
$ yarn install
$ yarn transform
$ yarn runOut
```

---
_Source: https://npm.io/package/babel-plugin-logfunctionname · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
