Full Code of TaroXin/vue-pretty-logger for AI

master 0ca3491517e0 cached
23 files
53.5 KB
15.1k tokens
3 symbols
1 requests
Download .txt
Repository: TaroXin/vue-pretty-logger
Branch: master
Commit: 0ca3491517e0
Files: 23
Total size: 53.5 KB

Directory structure:
gitextract_mhxvg_ky/

├── .babelrc
├── .gitignore
├── .npmignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── example/
│   ├── example.js
│   ├── index.html
│   ├── main.js
│   ├── source.vue
│   └── webpack.config.js
├── index.js
├── lib/
│   ├── constant/
│   │   ├── logger-types.js
│   │   └── options.js
│   ├── in-js.js
│   ├── index.js
│   └── utils/
│       ├── logger-note-judge.js
│       ├── logger-parser.js
│       └── logger-type-judge.js
├── package.json
└── test/
    ├── loader-type-judge.test.js
    └── logger-parser.test.js

================================================
FILE CONTENTS
================================================

================================================
FILE: .babelrc
================================================
{
    "presets": ["env"],
    "plugins": [
        "transform-runtime"
    ]
}

================================================
FILE: .gitignore
================================================
.DS_Store
node_modules
*.log
example/dist

================================================
FILE: .npmignore
================================================
test
example
yarn.lock


================================================
FILE: .travis.yml
================================================
language: node_js
node_js:
  - "8"

================================================
FILE: CHANGELOG.md
================================================
<a name="0.9.0"></a>
# 0.9.0 (2018-05-09)


### Bug Fixes

* fix bug 'loaderContext is not defined' ([a03dacf](https://github.com/TaroXin/vue-pretty-logger/commit/a03dacf))
* fix bug: Cannot read property 'content' of null. ([6956668](https://github.com/TaroXin/vue-pretty-logger/commit/6956668)), closes [#1](https://github.com/TaroXin/vue-pretty-logger/issues/1)


### Features

* add -stop to stop default actions ([230bfc1](https://github.com/TaroXin/vue-pretty-logger/commit/230bfc1))
* add await statement comment compiler ([469294f](https://github.com/TaroXin/vue-pretty-logger/commit/469294f)), closes [#3](https://github.com/TaroXin/vue-pretty-logger/issues/3)
* add command that control the currently displayed tag ([46dd72b](https://github.com/TaroXin/vue-pretty-logger/commit/46dd72b))
* add console for function declarations and call ([d6905e1](https://github.com/TaroXin/vue-pretty-logger/commit/d6905e1))
* add control of the log output type ([509cea6](https://github.com/TaroXin/vue-pretty-logger/commit/509cea6))
* add function callback and lambda callback comment compiler ([d8eaa9e](https://github.com/TaroXin/vue-pretty-logger/commit/d8eaa9e)), closes [#2](https://github.com/TaroXin/vue-pretty-logger/issues/2)
* add support for js files ([fe36184](https://github.com/TaroXin/vue-pretty-logger/commit/fe36184)), closes [#8](https://github.com/TaroXin/vue-pretty-logger/issues/8)
* add the -count command to display the number of the function calls ([d659577](https://github.com/TaroXin/vue-pretty-logger/commit/d659577))
* add the -from command to output function call parameters ([851512e](https://github.com/TaroXin/vue-pretty-logger/commit/851512e)), closes [#5](https://github.com/TaroXin/vue-pretty-logger/issues/5)
* add the -sign command to display the corresponding key value of the output value ([a3378a3](https://github.com/TaroXin/vue-pretty-logger/commit/a3378a3))
* add the -time -profile command ([ef38e85](https://github.com/TaroXin/vue-pretty-logger/commit/ef38e85))
* add the judgment of the NODE_ENV ([c61b081](https://github.com/TaroXin/vue-pretty-logger/commit/c61b081))
* add the option of the log hook ([2914afc](https://github.com/TaroXin/vue-pretty-logger/commit/2914afc))


### BREAKING CHANGES

* add support for js files
* add function logger
* add await statement comment compiler
* add function callback and lambda callback comment compiler
* add the option of the log hook
* add the judgment of the NODE_ENV
* add the -from command to output function call parameters
* add -time -profile command
* add -count command
* add -sign command
* add control of the log output type
* add -stop command to stop default actions



<a name="0.9.0"></a>
# 0.9.0 (2018-05-09)


### Bug Fixes

* fix bug: Cannot read property 'content' of null. ([6956668](https://github.com/TaroXin/vue-pretty-logger/commit/6956668)), closes [#1](https://github.com/TaroXin/vue-pretty-logger/issues/1)


### Features

* add -stop to stop default actions ([230bfc1](https://github.com/TaroXin/vue-pretty-logger/commit/230bfc1))
* add await statement comment compiler ([469294f](https://github.com/TaroXin/vue-pretty-logger/commit/469294f)), closes [#3](https://github.com/TaroXin/vue-pretty-logger/issues/3)
* add command that control the currently displayed tag ([46dd72b](https://github.com/TaroXin/vue-pretty-logger/commit/46dd72b))
* add console for function declarations and call ([d6905e1](https://github.com/TaroXin/vue-pretty-logger/commit/d6905e1))
* add control of the log output type ([509cea6](https://github.com/TaroXin/vue-pretty-logger/commit/509cea6))
* add function callback and lambda callback comment compiler ([d8eaa9e](https://github.com/TaroXin/vue-pretty-logger/commit/d8eaa9e)), closes [#2](https://github.com/TaroXin/vue-pretty-logger/issues/2)
* add support for js files ([fe36184](https://github.com/TaroXin/vue-pretty-logger/commit/fe36184)), closes [#8](https://github.com/TaroXin/vue-pretty-logger/issues/8)
* add the -count command to display the number of the function calls ([d659577](https://github.com/TaroXin/vue-pretty-logger/commit/d659577))
* add the -from command to output function call parameters ([851512e](https://github.com/TaroXin/vue-pretty-logger/commit/851512e)), closes [#5](https://github.com/TaroXin/vue-pretty-logger/issues/5)
* add the -sign command to display the corresponding key value of the output value ([a3378a3](https://github.com/TaroXin/vue-pretty-logger/commit/a3378a3))
* add the -time -profile command ([ef38e85](https://github.com/TaroXin/vue-pretty-logger/commit/ef38e85))
* add the judgment of the NODE_ENV ([c61b081](https://github.com/TaroXin/vue-pretty-logger/commit/c61b081))
* add the option of the log hook ([2914afc](https://github.com/TaroXin/vue-pretty-logger/commit/2914afc))


### BREAKING CHANGES

* add support for js files
* add function logger
* add await statement comment compiler
* add function callback and lambda callback comment compiler
* add the option of the log hook
* add the judgment of the NODE_ENV
* add the -from command to output function call parameters
* add -time -profile command
* add -count command
* add -sign command
* add control of the log output type
* add -stop command to stop default actions



<a name="0.8.9"></a>
## 0.8.9 (2018-05-09)


### Bug Fixes

* fix bug: Cannot read property 'content' of null. ([6956668](https://github.com/TaroXin/vue-pretty-logger/commit/6956668)), closes [#1](https://github.com/TaroXin/vue-pretty-logger/issues/1)


### Features

* add -stop to stop default actions ([230bfc1](https://github.com/TaroXin/vue-pretty-logger/commit/230bfc1))
* add await statement comment compiler ([469294f](https://github.com/TaroXin/vue-pretty-logger/commit/469294f)), closes [#3](https://github.com/TaroXin/vue-pretty-logger/issues/3)
* add command that control the currently displayed tag ([46dd72b](https://github.com/TaroXin/vue-pretty-logger/commit/46dd72b))
* add console for function declarations and call ([d6905e1](https://github.com/TaroXin/vue-pretty-logger/commit/d6905e1))
* add control of the log output type ([509cea6](https://github.com/TaroXin/vue-pretty-logger/commit/509cea6))
* add function callback and lambda callback comment compiler ([d8eaa9e](https://github.com/TaroXin/vue-pretty-logger/commit/d8eaa9e)), closes [#2](https://github.com/TaroXin/vue-pretty-logger/issues/2)
* add support for js files ([fe36184](https://github.com/TaroXin/vue-pretty-logger/commit/fe36184)), closes [#8](https://github.com/TaroXin/vue-pretty-logger/issues/8)
* add the -count command to display the number of the function calls ([d659577](https://github.com/TaroXin/vue-pretty-logger/commit/d659577))
* add the -from command to output function call parameters ([851512e](https://github.com/TaroXin/vue-pretty-logger/commit/851512e)), closes [#5](https://github.com/TaroXin/vue-pretty-logger/issues/5)
* add the -sign command to display the corresponding key value of the output value ([a3378a3](https://github.com/TaroXin/vue-pretty-logger/commit/a3378a3))
* add the -time -profile command ([ef38e85](https://github.com/TaroXin/vue-pretty-logger/commit/ef38e85))
* add the judgment of the NODE_ENV ([c61b081](https://github.com/TaroXin/vue-pretty-logger/commit/c61b081))
* add the option of the log hook ([2914afc](https://github.com/TaroXin/vue-pretty-logger/commit/2914afc))


### BREAKING CHANGES

* add support for js files
* add function logger
* add await statement comment compiler
* add function callback and lambda callback comment compiler
* add the option of the log hook
* add the judgment of the NODE_ENV
* add the -from command to output function call parameters
* add -time -profile command
* add -count command
* add -sign command
* add control of the log output type
* add -stop command to stop default actions



<a name="0.8.9"></a>
## 0.8.9 (2018-05-09)


### Bug Fixes

* fix bug: Cannot read property 'content' of null. ([6956668](https://github.com/TaroXin/vue-pretty-logger/commit/6956668)), closes [#1](https://github.com/TaroXin/vue-pretty-logger/issues/1)


### Features

* add -stop to stop default actions ([230bfc1](https://github.com/TaroXin/vue-pretty-logger/commit/230bfc1))
* add await statement comment compiler ([469294f](https://github.com/TaroXin/vue-pretty-logger/commit/469294f)), closes [#3](https://github.com/TaroXin/vue-pretty-logger/issues/3)
* add command that control the currently displayed tag ([46dd72b](https://github.com/TaroXin/vue-pretty-logger/commit/46dd72b))
* add console for function declarations and call ([d6905e1](https://github.com/TaroXin/vue-pretty-logger/commit/d6905e1))
* add control of the log output type ([509cea6](https://github.com/TaroXin/vue-pretty-logger/commit/509cea6))
* add function callback and lambda callback comment compiler ([d8eaa9e](https://github.com/TaroXin/vue-pretty-logger/commit/d8eaa9e)), closes [#2](https://github.com/TaroXin/vue-pretty-logger/issues/2)
* add the -count command to display the number of the function calls ([d659577](https://github.com/TaroXin/vue-pretty-logger/commit/d659577))
* add the -from command to output function call parameters ([851512e](https://github.com/TaroXin/vue-pretty-logger/commit/851512e)), closes [#5](https://github.com/TaroXin/vue-pretty-logger/issues/5)
* add the -sign command to display the corresponding key value of the output value ([a3378a3](https://github.com/TaroXin/vue-pretty-logger/commit/a3378a3))
* add the -time -profile command ([ef38e85](https://github.com/TaroXin/vue-pretty-logger/commit/ef38e85))
* add the judgment of the NODE_ENV ([c61b081](https://github.com/TaroXin/vue-pretty-logger/commit/c61b081))
* add the option of the log hook ([2914afc](https://github.com/TaroXin/vue-pretty-logger/commit/2914afc))


### BREAKING CHANGES

* add the -from command to output function call parameters
* add function logger
* add function callback and lambda callback comment compiler
* add the option of the log hook
* add the judgment of the NODE_ENV
* add await statement comment compiler
* add -time -profile command
* add -count command
* add -sign command
* add control of the log output type
* add -stop command to stop default actions



<a name="0.8.7"></a>
## 0.8.7 (2018-05-09)


### Bug Fixes

* fix bug: Cannot read property 'content' of null. ([6956668](https://github.com/TaroXin/vue-pretty-logger/commit/6956668)), closes [#1](https://github.com/TaroXin/vue-pretty-logger/issues/1)


### Features

* add -stop to stop default actions ([230bfc1](https://github.com/TaroXin/vue-pretty-logger/commit/230bfc1))
* add await statement comment compiler ([469294f](https://github.com/TaroXin/vue-pretty-logger/commit/469294f)), closes [#3](https://github.com/TaroXin/vue-pretty-logger/issues/3)
* add command that control the currently displayed tag ([46dd72b](https://github.com/TaroXin/vue-pretty-logger/commit/46dd72b))
* add console for function declarations and call ([d6905e1](https://github.com/TaroXin/vue-pretty-logger/commit/d6905e1))
* add control of the log output type ([509cea6](https://github.com/TaroXin/vue-pretty-logger/commit/509cea6))
* add function callback and lambda callback comment compiler ([d8eaa9e](https://github.com/TaroXin/vue-pretty-logger/commit/d8eaa9e)), closes [#2](https://github.com/TaroXin/vue-pretty-logger/issues/2)
* add the -count command to display the number of the function calls ([d659577](https://github.com/TaroXin/vue-pretty-logger/commit/d659577))
* add the -sign command to display the corresponding key value of the output value ([a3378a3](https://github.com/TaroXin/vue-pretty-logger/commit/a3378a3))
* add the -time -profile command ([ef38e85](https://github.com/TaroXin/vue-pretty-logger/commit/ef38e85))
* add the judgment of the NODE_ENV ([c61b081](https://github.com/TaroXin/vue-pretty-logger/commit/c61b081))
* add the option of the log hook ([2914afc](https://github.com/TaroXin/vue-pretty-logger/commit/2914afc))


### BREAKING CHANGES

* add await statement comment compiler
* add function callback and lambda callback comment compiler
* add the option of the log hook
* add the judgment of the NODE_ENV
* add -stop command to stop default actions
* add -time -profile command
* add -count command
* add -sign command
* add control of the log output type
* add function logger



<a name="0.8.7"></a>
## 0.8.7 (2018-05-08)


### Bug Fixes

* fix bug: Cannot read property 'content' of null. ([6956668](https://github.com/TaroXin/vue-pretty-logger/commit/6956668)), closes [#1](https://github.com/TaroXin/vue-pretty-logger/issues/1)


### Features

* add -stop to stop default actions ([230bfc1](https://github.com/TaroXin/vue-pretty-logger/commit/230bfc1))
* add await statement comment compiler ([469294f](https://github.com/TaroXin/vue-pretty-logger/commit/469294f)), closes [#3](https://github.com/TaroXin/vue-pretty-logger/issues/3)
* add command that control the currently displayed tag ([46dd72b](https://github.com/TaroXin/vue-pretty-logger/commit/46dd72b))
* add console for function declarations and call ([d6905e1](https://github.com/TaroXin/vue-pretty-logger/commit/d6905e1))
* add control of the log output type ([509cea6](https://github.com/TaroXin/vue-pretty-logger/commit/509cea6))
* add function callback and lambda callback comment compiler ([d8eaa9e](https://github.com/TaroXin/vue-pretty-logger/commit/d8eaa9e)), closes [#2](https://github.com/TaroXin/vue-pretty-logger/issues/2)
* add the -count command to display the number of the function calls ([d659577](https://github.com/TaroXin/vue-pretty-logger/commit/d659577))
* add the -sign command to display the corresponding key value of the output value ([a3378a3](https://github.com/TaroXin/vue-pretty-logger/commit/a3378a3))
* add the -time -profile command ([ef38e85](https://github.com/TaroXin/vue-pretty-logger/commit/ef38e85))
* add the judgment of the NODE_ENV ([c61b081](https://github.com/TaroXin/vue-pretty-logger/commit/c61b081))
* add the option of the log hook ([2914afc](https://github.com/TaroXin/vue-pretty-logger/commit/2914afc))


### BREAKING CHANGES

* add await statement comment compiler
* add function callback and lambda callback comment compiler
* add the option of the log hook
* add the judgment of the NODE_ENV
* add -stop command to stop default actions
* add -time -profile command
* add -count command
* add -sign command
* add control of the log output type
* add function logger



<a name="0.8.3"></a>
## 0.8.3 (2018-05-06)


### Features

* add -stop to stop default actions ([230bfc1](https://github.com/TaroXin/vue-pretty-logger/commit/230bfc1))
* add command that control the currently displayed tag ([46dd72b](https://github.com/TaroXin/vue-pretty-logger/commit/46dd72b))
* add console for function declarations and call ([d6905e1](https://github.com/TaroXin/vue-pretty-logger/commit/d6905e1))
* add control of the log output type ([509cea6](https://github.com/TaroXin/vue-pretty-logger/commit/509cea6))
* add the -count command to display the number of the function calls ([d659577](https://github.com/TaroXin/vue-pretty-logger/commit/d659577))
* add the -sign command to display the corresponding key value of the output value ([a3378a3](https://github.com/TaroXin/vue-pretty-logger/commit/a3378a3))
* add the -time -profile command ([ef38e85](https://github.com/TaroXin/vue-pretty-logger/commit/ef38e85))
* add the judgment of the NODE_ENV ([c61b081](https://github.com/TaroXin/vue-pretty-logger/commit/c61b081))
* add the option of the log hook ([2914afc](https://github.com/TaroXin/vue-pretty-logger/commit/2914afc))


### BREAKING CHANGES

* add the option of the log hook
* add the judgment of the NODE_ENV
* add -stop command to stop default actions
* add -time -profile command
* add -count command
* add -sign command
* add control of the log output type
* add function logger



<a name="0.8.0"></a>
# 0.8.0 (2018-05-06)


### Features

* add -stop to stop default actions ([230bfc1](https://github.com/TaroXin/vue-pretty-logger/commit/230bfc1))
* add command that control the currently displayed tag ([46dd72b](https://github.com/TaroXin/vue-pretty-logger/commit/46dd72b))
* add console for function declarations and call ([d6905e1](https://github.com/TaroXin/vue-pretty-logger/commit/d6905e1))
* add control of the log output type ([509cea6](https://github.com/TaroXin/vue-pretty-logger/commit/509cea6))
* add the -count command to display the number of the function calls ([d659577](https://github.com/TaroXin/vue-pretty-logger/commit/d659577))
* add the -sign command to display the corresponding key value of the output value ([a3378a3](https://github.com/TaroXin/vue-pretty-logger/commit/a3378a3))
* add the -time -profile command ([ef38e85](https://github.com/TaroXin/vue-pretty-logger/commit/ef38e85))


### BREAKING CHANGES

* add -stop command to stop default actions
* add -time -profile command
* add -count command
* add -sign command
* add control of the log output type
* add function logger



<a name="0.7.0"></a>
# 0.7.0 (2018-05-06)


### Features

* add command that control the currently displayed tag ([46dd72b](https://github.com/TaroXin/vue-pretty-logger/commit/46dd72b))
* add console for function declarations and call ([d6905e1](https://github.com/TaroXin/vue-pretty-logger/commit/d6905e1))
* add control of the log output type ([509cea6](https://github.com/TaroXin/vue-pretty-logger/commit/509cea6))
* add the -count command to display the number of the function calls ([d659577](https://github.com/TaroXin/vue-pretty-logger/commit/d659577))
* add the -sign command to display the corresponding key value of the output value ([a3378a3](https://github.com/TaroXin/vue-pretty-logger/commit/a3378a3))
* add the -time -profile command ([ef38e85](https://github.com/TaroXin/vue-pretty-logger/commit/ef38e85))


### BREAKING CHANGES

* add -time -profile command
* add -count command
* add -sign command
* add control of the log output type
* add function logger



<a name="0.7.0"></a>
# 0.7.0 (2018-05-06)


### Features

* add command that control the currently displayed tag ([46dd72b](https://github.com/TaroXin/vue-pretty-logger/commit/46dd72b))
* add console for function declarations and call ([d6905e1](https://github.com/TaroXin/vue-pretty-logger/commit/d6905e1))
* add control of the log output type ([509cea6](https://github.com/TaroXin/vue-pretty-logger/commit/509cea6))
* add the -count command to display the number of the function calls ([d659577](https://github.com/TaroXin/vue-pretty-logger/commit/d659577))
* add the -sign command to display the corresponding key value of the output value ([a3378a3](https://github.com/TaroXin/vue-pretty-logger/commit/a3378a3))
* add the -time -profile command ([ef38e85](https://github.com/TaroXin/vue-pretty-logger/commit/ef38e85))


### BREAKING CHANGES

* add -time -profile command
* add -count command
* add -sign command
* add control of the log output type
* add function logger



<a name="0.5.2"></a>
## 0.5.2 (2018-05-06)


### Features

* add command that control the currently displayed tag ([46dd72b](https://github.com/TaroXin/vue-pretty-logger/commit/46dd72b))
* add console for function declarations and call ([d6905e1](https://github.com/TaroXin/vue-pretty-logger/commit/d6905e1))
* add control of the log output type ([509cea6](https://github.com/TaroXin/vue-pretty-logger/commit/509cea6))
* add the -sign command to display the corresponding key value of the output value ([a3378a3](https://github.com/TaroXin/vue-pretty-logger/commit/a3378a3))


### BREAKING CHANGES

* add -sign command
* add control of the log output type
* add function logger



<a name="0.4.0"></a>
# 0.4.0 (2018-05-05)


### Features

* add console for function declarations and call ([d6905e1](https://github.com/TaroXin/vue-pretty-logger/commit/d6905e1))
* add control of the log output type ([509cea6](https://github.com/TaroXin/vue-pretty-logger/commit/509cea6))


### BREAKING CHANGES

* add control of the log output type
* add function logger



<a name="0.3.0"></a>
# 0.3.0 (2018-05-05)


### Features

* add console for function declarations and call ([d6905e1](https://github.com/TaroXin/vue-pretty-logger/commit/d6905e1))
* add control of the log output type ([509cea6](https://github.com/TaroXin/vue-pretty-logger/commit/509cea6))


### BREAKING CHANGES

* add control of the log output type
* add function logger



<a name="0.3.0"></a>
# 0.3.0 (2018-05-04)


### Features

* add console for function declarations and call ([d6905e1](https://github.com/TaroXin/vue-pretty-logger/commit/d6905e1))


### BREAKING CHANGES

* add function logger



<a name="0.0.1"></a>
## 0.0.1 (2018-05-04)





================================================
FILE: LICENSE
================================================
MIT License

Copyright (c) 2018 杨鑫

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.


================================================
FILE: README.md
================================================
# vue-pretty-logger

[![Scrutinizer Build](https://img.shields.io/npm/v/vue-pretty-logger.svg?style=for-the-badge)](https://www.npmjs.com/package/vue-pretty-logger) [![Scrutinizer Build](https://img.shields.io/scrutinizer/build/g/filp/whoops.svg?style=for-the-badge)](https://travis-ci.org/TaroXin/vue-pretty-logger) [![npm](https://img.shields.io/npm/l/express.svg?style=for-the-badge)
](https://opensource.org/licenses/mit-license.php)


[README for Chinese](https://juejin.im/post/5aef271c51882506a36c69a7)
### Table of content

* [Introduce](#introduce)
* [Install](#install)
* [Usage](#usage)
* [Example](#example)
* [Options](#options)
* [Commands](#commands)
* [Change Log](#changeLog)

<span id="introduce"></span>
### What is Vue pretty logger loader ?
`vue-pretty-logger` is a loader for webpack, you can use it  in your .vue file

``` vue
<template>
  <div>This is Test Message</div>
</template>

<script>
  export default {
    mounted () {
      let a = 123 // {#}

      let str = 'Test' // {#}
    }
  }
</script>
```

### You don't know what to do?

``` javascript
/**
 * // {#} is hook
 * So the result is the console prints 123.
 * Did you feel cool?
 */
let a = 123 // {#}
```

<span id="install"></span>
### Install

``` javascript
npm install vue-pretty-logger -D
// or
yarn add --dev vue-pretty-logger
```
 **in your webpack config file** 
> **NOTE:** `vue-pretty-logger` must be executed prior to `vue-loader`, Putting it at the bottom of the list of loaders is the best choice
``` javascript
...
module: {
  rules: [
    {
      test: /\.vue$/,
      use: [
        {
          loader: 'vue-loader'
        },
        {
          loader: 'vue-pretty-logger',
          options: {
            ...
          }
        }
      ]
    }
  ]
}
...
```

<span id="usage"></span>
### Usage

**in your vue file**
``` vue
<template>
  <div>Cool console</div>
</template>

<script>
  export default {
    mounted () {
      let a = 123 // {#}
      // equals: console.log(a)

      a = 456 // {#}
      // equals: console.log(a)
    
      this.testFunc1()

      this.testFunc2('test') // {#}
      /**
        * equals:
        * const result = this.testFunc2('test')
        * console.log(result)
        */
    },

    methods: {
      testFunc1 (a, b) { // {#}
        // equals: console.log(a, b)
      },

      testFunc2 (a) {
        return a
      }
    }
  }
</script>
```

<span id="example"></span>
### Example
Example can be found in `example/`

<span id="options"></span>
### Options

* **tag**
`Globally specified log display tag`
`default: ''`
* **hook**
`Globally specified log Hook`
`default: '#'`
* **infoTag**
`Globally specified log info tag`
`default: 'INFO'`
* **infoTagStyle**
`Globally specified log info tag style`
`default: ''`
* **error, debug, warn are the same as info**
 
<span id="commands"></span>
### Commands

* **-e**
`Output as error`
* **-d**
`Output as debug`
* **-w**
`Output as warn`
* **-i**
`Output as info`
* **-t**
`Specify local log comment tag`
* **-sign**
`The variable name corresponding to the output value when outputting the value`
* **-count**
`Number of times the output function was called`
`Only valid at function declaration`
* **-time**
`Output function execution time-consunming`
`Only valid at function call`
* **-profile**
`Create a profile for your function`
`Only valid at function call`
* **-stop**
`Stop default actions`

<span id="changeLog"></span>
### Change Log
* `V0.9.0` [issues](https://github.com/TaroXin/vue-pretty-logger/issues/8)
``` javascript
// add support for js files

{
    test: /\.js$/,
    use: ['babel-loader', 'vue-pretty-logger/lib/in-js'],
    exclude: /node_modules/
}
```

* `V0.8.8` [issues](https://github.com/TaroXin/vue-pretty-logger/issues/5)
``` javascript
// add the -form command

this.testFuncCall(p1, p2) // {#} -sign -from

// equals:
console.log(`p1: ${p1}, p2: ${p2}`)
const result = this.testFuncCall(p1, p2)
console.log(`result: ${result}`)
```

* `V0.8.7` [issues](https://github.com/TaroXin/vue-pretty-logger/issues/3)
``` javascript
// Add support for await statements, consistent with function call

await test() // {#} -e -sign -time
// equals: const result = await test(); console.error(`result: ${result}`)
```

* `V0.8.6` [issues](https://github.com/TaroXin/vue-pretty-logger/issues/2)
``` javascript
// Support callback function use, output callback function parameters.

this.$bus.$on('gotData', (data) => { // {#} -i -sign
    // equals: console.info(`data: ${data}`)
})

this.$bus.$on('gotData', function (data) { // {#} -i -sign
    // equals: console.info(`data: ${data}`)
})

```

* `V0.8.5` [issues](https://github.com/TaroXin/vue-pretty-logger/issues/1)
```
fix bug: Can not read property 'content' of null
```



================================================
FILE: example/example.js
================================================
function Example (test) { // {#} -sign -w -t Example
    let a = 123

    testFunc(a) // {#} -sign -i -from -time -profile

    testFuncCallback((val) => { // {#} -sign -d
        // do something
    })
}

function testFunc (form) {
    return 'Return me!'
}

function testFuncCallback (cb) {
    cb && cb('Callback return me')
}

export default Example

================================================
FILE: example/index.html
================================================
<style>
    html, body {
        margin: 0; padding: 0;
    }
</style>
<div id="app"></div>
<script src="/dist/bundle.js"></script>

================================================
FILE: example/main.js
================================================
import Vue from 'vue'
import Foo from './source.vue'
import Example from './example.js'

Example('I\' a test str')

new Vue({
    el: '#app',
    render: h => h(Foo)
})

================================================
FILE: example/source.vue
================================================
<template>
    <div class="container">
        <header class="header">Vue-Pretty-Logger</header>
        <section class="section">
            The console is more cool to use, easier to debug, and more fun log output. Enjoy the vue-pretty-logger in the vue project.
        </section>
        <section class="section">
            npm install vue-pretty-logger -D
            <br><br>
            yarn add --dev vue-pretty-logger
        </section>
        <section class="section">
           Please press F12 !!!
        </section>
    </div>
</template>

<script>
    export default {
        data () {
            return {
                tes$tObj: {
                    test (str1, func2) {
                        func2(str1)
                    }
                }
            }
        },
        mounted () {
            // /**
            //  * test assignment
            //  */
            let a = 123 // {#} -sign

            // let b
            // b = 456 // {#} -i -t TEST -sign

            // /**
            //  * test function declaration
            //  */
            // this.testFunc1("This is testFunc1")
            // this.testFunc2("This is testFunc2", {
            //     name: 'Yangxin',
            //     age: '15'
            // })

            // /**
            //  * test function call
            //  */
            // this.testFunc3() // {#} -w -sign
            
            // // no support for the time being
            // // this.testFunc4(1, { // {#}
            // //     count: 1
            // // }) 
            // // recommend to use this like this
            // this.testFunc4(1, {count: 1}) // {#}

            // this.testFunc5('with -time') // {LOG} -time -sign

            // this.testFunc6('with -profile') // {#} -stop -profile

            // let str1 = 'Hello World' // {#}



            // let str2 = 'Hello World' // {#} -e
            // let str3 = 'Hello World' // {#} -d
            // let str4 = 'Hello World' // {#} -w
            // let str5 = 'Hello World' // {#} -i

            // this.testFunc('Hello', 'World') // {#} -time -stop

            // this.tes$tObj.test('Return me!', (val) => { // {#} -e -sign

            // })
            // this.testLambda$().test((val) => { // {#} -e

            // }) 

            // this.testAsync()
            // this.testFunc("p1", "p2") 

            // this.testForm("hello", "world") // {#} -from -sign -e
        },

        methods: {
            testForm (p1, p2) { // {#} -sign
                
            },
            testFunc1 (testStr) { // {#} -e
                // console.log(testStr)
            },
            testFunc2 (testSrt1, testObject2) { // {#} -w -sign -count
                // console.count('test')
            },

            testFunc3 () {
                return 'Hello, I\'m return!'
            },

            testFunc4 (num, data) {
                return num + data.count
            },

            testFunc5 (command) {
                
            },
            
            testFunc6 (command) {

            },

            testFunc (p1, p2) { // {#} -i -t TestFunc -sign -count

            },

            testLambda$() {
                return {
                    test (func2) {
                        func2('Return Me!')
                    }
                }
            },

            async testAsync (p) { // {#} -sign
                async function test () { 
                    await test2() 
                }

                function test2 () {
                    return new Promise((resolve, reject) => {
                        resolve('I am return')
                    })
                }

                test().then((val) => {
                    console.log(val)
                })
            }
        }
    }
</script>


<style scoped>
    .container {
        width: 100%;
        height: 100%;
        background: #e9e9e9;
        font-family: 'Source Code Pro', 'Courier New', Courier, monospace 
    }
    .header {
        position: relative;
        height: 150px;
        text-align: center;
        top: 100px;
        font-size: 80px;
        font-weight: bold;
        color: #41B883;
        user-select: none;
        -webkit-user-select: none;
    }

    .section {
        position: relative;
        top: 60px;
        width: 700px;
        padding: 15px 25px;
        box-sizing: border-box;
        margin: 0 auto;
        background: #333;
        color: #FFF;
        margin-bottom: 15px;
    }
</style>


================================================
FILE: example/webpack.config.js
================================================
const path = require('path')
const VueLoaderPlugin = require('vue-loader/lib/plugin.js')

module.exports = {
    mode: 'development',
    entry: path.join(__dirname, './main.js'),
    output: {
        path: path.join(__dirname, 'dist'),
        filename: 'bundle.js',
        publicPath: '/dist/'
    },
    devServer: {
        stats: 'minimal',
        contentBase: __dirname
    },
    module: {
        rules: [
            {
                test: /\.vue$/,
                use: [
                    {
                        loader: 'vue-loader'
                    },
                    {
                        loader: path.join(__dirname, '../lib/index.js'),
                        options: {
                            tag: 'Pretty_Logger',
                            hook: '#'
                        }
                    }
                ]
            },
            {
                test: /\.css$/,
                use: ['style-loader', 'css-loader']
            },
            {
                test: /\.js$/,
                use: ['babel-loader', path.join(__dirname, '../lib/in-js.js')],
                exclude: /node_modules/
            }
        ]
    },
    plugins: [
        new VueLoaderPlugin()
    ]
}

================================================
FILE: index.js
================================================
const loader = require('./loader')

module.exports = loader


================================================
FILE: lib/constant/logger-types.js
================================================
module.exports = {
    FUNCTION: 'FUNCTION',
    FUNCTION_CALL: 'FUNCTION_CALL',
    ASSIGNMENT: 'ASSIGNMENT',
    FUNCTION_CALLBACK: 'FUNCTION_CALLBACK'
}


================================================
FILE: lib/constant/options.js
================================================
module.exports = {
    tag: '',
    dev: true,
    hook: '#',
    tagStyle: '',

    infoTag: 'INFO',
    infoTagStyle: 'color: #3838AD; font-weight: bold;',
    infoContentStyle: 'color: #333333, font-weight: bold;',

    warnTag: 'WARN',
    warnTagStyle: 'color: #DA9D32; font-weight: bold;',
    warnContentStyle: 'color: #333333, font-weight: bold;',

    debugTag: 'DEBUG',
    debugTagStyle: 'color: #22D015; font-weight: bold;',
    debugContentStyle: 'color: #333333, font-weight: bold;',

    errorTag: 'ERROR',
    errorTagStyle: 'color: #CD2931; font-weight: bold;',
    errorContentStyle: 'color: #333333, font-weight: bold;',
}

================================================
FILE: lib/in-js.js
================================================
// Vue-pretty-logger-loader
const loaderUtils = require('loader-utils')
const compiler = require('vue-template-compiler')
const loggerParser = require('./utils/logger-parser')
const defaultOptions = require('./constant/options')

module.exports = function (source, map) {
    const loaderContext = this
    loaderContext.cacheable && loaderContext.cacheable()

    const {
        resourcePath
    } = loaderContext
    
    const isJsFile = /\.js$/.test(resourcePath)

    // default options
    const options = Object.assign(
        defaultOptions,
        loaderUtils.getOptions(this)
    )

    // script has logger note ?
    let isScriptHasLoggerLine = false

    // get scripts
    let scripts = ''
    if (isJsFile) {
        scripts = source
    } else {
        return source
    }

    let scriptArray = scripts.split(/\r?\n/)
    // parse logger
    scriptArray = scriptArray.map(scriptLine => {
        if (loggerParser.isLoggerLine(scriptLine, options)) {
            // is logger line
            isScriptHasLoggerLine = true
            return loggerParser.parseLogger(scriptLine, options)
        } else {
            return scriptLine
        }
    })

    // do replace
    if (isScriptHasLoggerLine && scriptArray.length > 0) {
        source = scriptArray.join('\n')
    }
    
    return source
}


================================================
FILE: lib/index.js
================================================
// Vue-pretty-logger-loader
const loaderUtils = require('loader-utils')
const compiler = require('vue-template-compiler')
const loggerParser = require('./utils/logger-parser')
const defaultOptions = require('./constant/options')

module.exports = function (source, map) {
    this.cacheable && this.cacheable()

    // default options
    const options = Object.assign(
        defaultOptions,
        loaderUtils.getOptions(this)
    )

    // script has logger note ?
    let isScriptHasLoggerLine = false

    // get scripts
    const { script } = compiler.parseComponent(source, { pad: 'line' })
    if (script === null) {
        return source
    }

    const scripts = script.content

    let scriptArray = scripts.split(/\r?\n/)
    // parse logger
    scriptArray = scriptArray.map(scriptLine => {
        if (loggerParser.isLoggerLine(scriptLine, options)) {
            // is logger line
            isScriptHasLoggerLine = true
            return loggerParser.parseLogger(scriptLine, options)
        } else {
            return scriptLine
        }
    })

    // do replace
    if (isScriptHasLoggerLine && scriptArray.length > 0) {
        source = source.replace(
            /<script[^>]*?>[\s\S]*?<\/script>/i,
            '<script>' + scriptArray.join('\n') + '</script>'
        )
    }
    
    return source
}


================================================
FILE: lib/utils/logger-note-judge.js
================================================
// logger-note-judge
const loggerNoteJudge = {
    tagCommand: '-t',
    signCommand: '-sign',
    countCommand: '-count',
    timeCommand: '-time',
    profileCommand: '-profile',
    stopCommand: '-stop',
    fromCommand: '-from',
    loggerLevels: [
        {
            name: '-e',
            value: 'error'
        },
        {
            name: '-d',
            value: 'debug'
        },
        {
            name: '-w',
            value: 'warn'
        },
        {
            name: '-i',
            value: 'info'
        },
    ]
}

loggerNoteJudge.generateNote = function(logger, options, ...consoleStrArr) {
    // logger => // {#} -d
    logger = logger.substring(`// {${options.hook}}`.length, logger.length).trim()
    let loggerCommands = logger.split(/\s+/)
    let consoleLine = ''
    
    // check -t
    let localTag = options.tag
    let tagIndex = loggerCommands.findIndex(comm => comm === loggerNoteJudge.tagCommand)
    if (tagIndex > -1) {
        localTag = loggerCommands[tagIndex + 1]
    }

    // find logger levels
    let currentLevel = loggerNoteJudge.loggerLevels.find(level => {
        for (let i = 0; i < loggerCommands.length; i++) {
            if (loggerCommands[i] === level.name) {
                // get
                return true
            }
        }
        return false
    })

    if (currentLevel) {
        let levelTag = `${currentLevel.value}Tag`
        let levelTagStyle = `${currentLevel.value}TagStyle`
        consoleLine += `console.${currentLevel.value}('%c[${options[levelTag]}][${localTag}]', '${options[levelTagStyle]}', `
        for (let i = 0; i < consoleStrArr.length; i++) {
            consoleLine += `${consoleStrArr[i]}`

            if (i !== consoleStrArr.length - 1) {
                consoleLine += ', '
            }
        }
        consoleLine += `)`
    } else {
        consoleLine += `console.log(`
        for (let i = 0; i < consoleStrArr.length; i++) {
            consoleLine += `${consoleStrArr[i]}`
            if (i !== consoleStrArr.length - 1) {
                consoleLine += ', '
            }
        }
        consoleLine += `)`
    }

    if (loggerCommands.indexOf(loggerNoteJudge.stopCommand) > -1) {
        consoleLine = ''
    }

    return consoleLine
}


loggerNoteJudge.hasSignCommand = function (logger, options) {
    logger = logger.substring(`// {${options.hook}}`.length, logger.length).trim()
    let loggerCommands = logger.split(/\s+/)
    return loggerCommands.indexOf(loggerNoteJudge.signCommand) > -1
}

loggerNoteJudge.withAssignment = function (loggerType, options) {
    let loggerLine = ''
    loggerLine += loggerType.input
    
    let consoleStrArr = []
    let hasSignCommand = loggerNoteJudge.hasSignCommand(loggerType.logger, options)
    if (hasSignCommand) {
        consoleStrArr.push(`'${loggerType.var}: '`)
    }
    consoleStrArr.push(loggerType.var)

    let generateNote = loggerNoteJudge.generateNote(loggerType.logger, options, consoleStrArr)
    loggerLine += '\n' + generateNote
    return loggerLine
}

loggerNoteJudge.withFunction = function (loggerType, options) {
    let loggerLine = ''
    loggerLine += loggerType.input
    let consoleStrArr = []
    let hasSignCommand = loggerNoteJudge.hasSignCommand(loggerType.logger, options)

    for (let i = 0; i < loggerType.var.length; i++) {
        if (hasSignCommand) {
            consoleStrArr.push(`'${loggerType.var[i]}: '`)
        }
        consoleStrArr.push(`${loggerType.var[i]}`)
    }
    
    if (loggerType.var.length > 0) {
        loggerLine += `\n` + loggerNoteJudge.generateNote(loggerType.logger, options, consoleStrArr)
    }

    // check -count
    let logger = loggerType.logger.substring(`// {${options.hook}}`.length, loggerType.logger.length).trim()
    let loggerCommands = logger.split(/\s+/)
    if (loggerCommands.indexOf(loggerNoteJudge.countCommand) > -1) {
        // has -count
        loggerLine += `\nconsole.count('${loggerType.functionName}')`
    }

    return loggerLine
}

loggerNoteJudge.withFunctionCall = function (loggerType, options) {
    let loggerLine = ''

    // check -time -profile -from
    let logger = loggerType.logger.substring(`// {${options.hook}}`.length, loggerType.logger.length).trim()
    let loggerCommands = logger.split(/\s+/)
    let hasTimeCommand = false
    let hasProfileCommand = false
    let hasFromCommand = false

    if (loggerCommands.indexOf(loggerNoteJudge.timeCommand) > -1) {
        hasTimeCommand = true
    }

    if (loggerCommands.indexOf(loggerNoteJudge.profileCommand) > -1) {
        hasProfileCommand = true
    }

    if (loggerCommands.indexOf(loggerNoteJudge.fromCommand) > -1) {
        hasFromCommand = true
    }

    if (hasProfileCommand) {
        loggerLine += `console.profile('${loggerType.functionName}')`
    }

    if (hasTimeCommand) {
        loggerLine += `\nconsole.time('${loggerType.functionName}')`
    }

    // check -from
    let consoleStrArr = []
    if (hasFromCommand) {
        let hasSignCommand = loggerNoteJudge.hasSignCommand(loggerType.logger, options)

        for (let i = 0; i < loggerType.var.length; i++) {
            if (hasSignCommand) {
                consoleStrArr.push(`'${loggerType.var[i]}: '`)
            }
            consoleStrArr.push(`${loggerType.var[i]}`)
        }

        if (loggerType.var.length > 0) {
            loggerLine += `\n` + loggerNoteJudge.generateNote(loggerType.logger, options, consoleStrArr)
        }
    }
    // check -form end

    let resultName = 'result_' + Math.floor(Math.random() * 100000000)
    loggerLine += `\nconst ${resultName} = ${loggerType.input}`

    if (hasTimeCommand) {
        loggerLine += `\nconsole.timeEnd('${loggerType.functionName}')`
    }

    if (hasProfileCommand) {
        loggerLine += `\nconsole.profileEnd('${loggerType.functionName}')`
    }


    consoleStrArr = []
    if (loggerNoteJudge.hasSignCommand(loggerType.logger, options)) {
        consoleStrArr.push(`'result: '`)
    }
    consoleStrArr.push(resultName)
    loggerLine += `\n` + loggerNoteJudge.generateNote(loggerType.logger, options, consoleStrArr)
    return loggerLine
}

loggerNoteJudge.withFunctionCallback = function (loggerType, options) {
    let loggerLine = ''
    loggerLine += loggerType.input
    let consoleStrArr = []
    let hasSignCommand = loggerNoteJudge.hasSignCommand(loggerType.logger, options)

    for (let i = 0; i < loggerType.var.length; i++) {
        if (hasSignCommand) {
            consoleStrArr.push(`'${loggerType.var[i]}: '`)
        }
        consoleStrArr.push(`${loggerType.var[i]}`)
    }
    
    if (loggerType.var.length > 0) {
        loggerLine += `\n` + loggerNoteJudge.generateNote(loggerType.logger, options, consoleStrArr)
    }

    return loggerLine
}

module.exports = loggerNoteJudge


================================================
FILE: lib/utils/logger-parser.js
================================================
// logger-parser
const typeJudge = require('./logger-type-judge')
const noteJudge = require('./logger-note-judge')
const loggerTypes = require('../constant/logger-types')

const isDevelopment = 
    process.env.NODE_ENV ? 
    (process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test') : 
    true

const loggerParser = {
    constant: {
        LOGGER_REG: /\/\/[^\n]*/
    }
}

loggerParser.isLoggerLine = function (line, options) {
    return line.indexOf(`// {${options.hook}}`) > -1
}

loggerParser.getLoggerNote = function (loggerLine, options) {
    const result = {}
    try {
        let contentArr = loggerParser.constant.LOGGER_REG.exec(loggerLine)
        result.logger = contentArr ? contentArr[0] : ''
        if (result.logger.indexOf(`// {${options.hook}}`) > -1) {
            result.input = contentArr.input
            result.index = contentArr.index
            return result
        } else {
            return loggerLine
        }
    } catch (error) {
        console.error('pretty-logger:', error)
        return loggerLine
    }
}

loggerParser.parseLogger = function (loggerLine, options) {
    // replace the current line with the options

    // get logger note
    const result = loggerParser.getLoggerNote(loggerLine, options)

    // judge the type of line that has logger
    const loggerType =
        typeJudge(result.logger, result.input, result.index) || {type: ''}

    if (!isDevelopment) {
        return loggerType.input
    }

    switch (loggerType.type) {
        case loggerTypes.ASSIGNMENT:
            loggerLine = noteJudge.withAssignment(loggerType, options)
            break
        case loggerTypes.FUNCTION:
            loggerLine = noteJudge.withFunction(loggerType, options)
            break
        case loggerTypes.FUNCTION_CALL:
            loggerLine = noteJudge.withFunctionCall(loggerType, options)
            break
        case loggerTypes.FUNCTION_CALLBACK:
            loggerLine = noteJudge.withFunctionCallback(loggerType, options)
        default:
            break
    }

    return loggerLine
}

module.exports = loggerParser


================================================
FILE: lib/utils/logger-type-judge.js
================================================
const loggerTypes = require('../constant/logger-types')

const assignmentTag = ['let', 'const', 'var']

module.exports = (logger, input, index) => {
    // whether it is an assignment line
    input = input.substring(0, index).trim()
    const result = {
        logger: logger,
        input: input,
        var: '',
        type: '',
        functionName: ''
    }

    // Assignment statement
    let assignmentVar = ''
    assignmentTag.forEach(tag => {
        if (input.indexOf(tag) > -1 && input.indexOf('=') > -1) {
            assignmentVar = input.substring(
                input.indexOf(tag) + tag.length,
                input.indexOf('=')
            ).trim()
        }
    })

    if (assignmentVar) {
        result.type = loggerTypes.ASSIGNMENT
        result.var = assignmentVar
        return result
    }

    // judge like this: a = 123
    if (input.indexOf('=') > -1 && input.indexOf('=>') === -1) {
        let splitArrayWithEqualSign = input.split('=')
        // result: "a = 1" => ["a","1"]
        if (splitArrayWithEqualSign.length === 2) {
            result.type = loggerTypes.ASSIGNMENT
            result.var = splitArrayWithEqualSign[0].trim()
            return result
        }
    }

    // Function declaration: function test (p1, p2, p3) { // {#}
    // avoid: let a = 'test(p1, p2) { //{#}'
    const isFuncReg = /^(function)?\s*[a-zA-Z0-9_$]+\s*\(.*\)\s*{$/
    if (isFuncReg.test(input)) {
        let startIndex = 0
        if (input.indexOf('function') > -1) {
            startIndex = 'function'.length + 1
        }
        let endIndex = input.indexOf('(')
        let functionName = input.substring(startIndex, endIndex).trim()

        let paramsString = input.match(/\(.+\)/)
        if (paramsString) {
            paramsString = paramsString[0]
            paramsString = paramsString.substring(1, paramsString.length - 1)
            if (paramsString.trim()) {
                result.type = loggerTypes.FUNCTION
                result.var = paramsString.split(',')
                result.functionName = functionName
                return result
            }
        } else {
            result.type = loggerTypes.FUNCTION
            result.var = []
            result.functionName = functionName
            return result
        }
    }

    // Function call: this.test() // {#}
    const isFuncCallReg = /^[\.a-zA-Z0-9_$]+\(.*\);?$/
    if (isFuncCallReg.test(input)  || input.indexOf('await') === 0) {
        let startIndex = 0
        if (input.indexOf('.') > -1) {
            startIndex = input.indexOf('.') + 1
        }
        let endIndex = input.indexOf('(')

        if (input.indexOf('await') === 0) {
            startIndex = 'await'.length + 1
            let awaitFuncEnd = input.indexOf('(')
            endIndex = awaitFuncEnd === -1 ? -1 : awaitFuncEnd
        }
        
        let functionName
        if (endIndex === -1) {
            functionName = 'await statement'
        } else {
            functionName = input.substring(startIndex, endIndex).trim()
        }

        startIndex = input.lastIndexOf('(') + 1
        endIndex = input.lastIndexOf(')')
        let paramsString = input.substring(startIndex, endIndex).trim()
        if (paramsString) {
            result.var = paramsString.split(',')
        } else {
            result.var = []
        }

        result.type = loggerTypes.FUNCTION_CALL
        result.functionName = functionName
        return result
    }

    // Function callback: this.test(() => { // {#}
    const isFuncCallbackReg = /^[\.a-zA-Z0-9_$]+\(.*(function)?\(.*\)\s*(=>)?\s*{$/
    if (isFuncCallbackReg.test(input)) {
        let startIndex = 0
        if (input.indexOf('.') > -1) {
            startIndex = input.indexOf('.') + 1
        }
        let endIndex = input.indexOf('(')
        let functionName = input.substring(startIndex, endIndex).trim()

        startIndex = input.lastIndexOf('(')
        endIndex = input.lastIndexOf(')')
        let paramsString = input.substring(startIndex + 1, endIndex).trim()
        
        result.type = loggerTypes.FUNCTION_CALLBACK
        result.functionName = functionName
        if (paramsString) {
            result.var = paramsString.split(',')
        } else {
            result.var = []
        }
        return result
    }

    return null
}


================================================
FILE: package.json
================================================
{
  "name": "vue-pretty-logger",
  "version": "0.9.0",
  "author": "YangXin",
  "description": "Pretty logger for Vue",
  "keywords": [
    "logger",
    "vue-pretty-logger",
    "pretty-logger",
    "pretty",
    "pretty-logger-loader",
    "logger-loader"
  ],
  "main": "lib/index.js",
  "scripts": {
    "test": "jest",
    "dev": "webpack-dev-server --config example/webpack.config.js --inline --hot",
    "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
    "pregit": "yarn test && yarn changelog",
    "git": "git add . && git cz",
    "postgit": "git push origin master && yarn publish"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/TaroXin/vue-pretty-logger.git"
  },
  "bugs": {
    "url": "https://github.com/TaroXin/vue-pretty-logger/issues"
  },
  "homepage": "https://github.com/TaroXin/vue-pretty-logger",
  "license": "MIT",
  "peerDependencies": {
    "loader-utils": "^1.1.0",
    "vue-template-compiler": "^2.5.16"
  },
  "devDependencies": {
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.4",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-env": "^1.6.1",
    "css-loader": "^0.28.11",
    "cz-conventional-changelog": "^2.1.0",
    "jest": "^22.4.3",
    "style-loader": "^0.21.0",
    "vue": "^2.5.16",
    "vue-loader": "^15.0.7",
    "vue-template-compiler": "^2.5.16",
    "webpack": "^4.7.0",
    "webpack-cli": "^2.1.2",
    "webpack-dev-server": "^3.1.4"
  },
  "config": {
    "commitizen": {
      "path": "./node_modules/cz-conventional-changelog"
    }
  }
}


================================================
FILE: test/loader-type-judge.test.js
================================================
const loggerTypeJudge = require('../lib/utils/logger-type-judge')

test('test loggerTypeJudge assignment', () => {
    const input = {
        logger: '// {#}',
        input: 'let a = 0 // {#}',
        index: 10
    }

    const output = {
        logger: '// {#}',
        input: 'let a = 0',
        var: 'a',
        type: 'ASSIGNMENT',
        functionName: ''
    }
    
    expect(JSON.stringify(loggerTypeJudge(input.logger, input.input, input.index))).toBe(JSON.stringify(output))
})

test('test loggerTypeJudge function', () => {
    const input = {
        logger: '// {#}',
        input: 'test (a, b) { // {#}',
        index: 14
    }

    const output = {
        logger: '// {#}',
        input: 'test (a, b) {',
        var: ['a', ' b'],
        type: 'FUNCTION',
        functionName: 'test'
    }
    
    expect(JSON.stringify(loggerTypeJudge(input.logger, input.input, input.index))).toBe(JSON.stringify(output))
})

test('test loggerTypeJudge function call', () => {
    const input = {
        logger: '// {#}',
        input: 'this.test(p1, p2) // {#}',
        index: 18
    }

    const output = {
        logger: '// {#}',
        input: 'this.test(p1, p2)',
        var: ['p1', ' p2'],
        type: 'FUNCTION_CALL',
        functionName: 'test'
    }
    
    expect(JSON.stringify(loggerTypeJudge(input.logger, input.input, input.index))).toBe(JSON.stringify(output))
})

test('test loggerTypeJudge function call with await', () => {
    const input = {
        logger: '// {#}',
        input: 'await test() // {#}',
        index: 13
    }

    const output = {
        logger: '// {#}',
        input: 'await test()',
        var: [],
        type: 'FUNCTION_CALL',
        functionName: 'test'
    }
    
    expect(JSON.stringify(loggerTypeJudge(input.logger, input.input, input.index))).toBe(JSON.stringify(output))
})

test('test loggerTypeJudge function callback', () => {
    const input = {
        logger: '// {#}',
        input: 'this.test("test", (result) => { // {#}',
        index: 32
    }

    const output = {
        logger: '// {#}',
        input: 'this.test("test", (result) => {',
        var: ['result'],
        type: 'FUNCTION_CALLBACK',
        functionName: 'test'
    }
    
    expect(JSON.stringify(loggerTypeJudge(input.logger, input.input, input.index))).toBe(JSON.stringify(output))
})


================================================
FILE: test/logger-parser.test.js
================================================
const loggerParser = require('../lib/utils/logger-parser')

test('test parse logger with normal', () => {
    let test = 'let a = 0 // {#}'
    let testResult = 'let a = 0\nconsole.log(a)'
    expect(loggerParser.parseLogger(test, {hook: '#'})).toBe(testResult)
})

test('test function declaration', () => {
    let test = 'test () { // {#}'
    let testResult = 'test () {'
    expect(loggerParser.parseLogger(test, {hook: '#'})).toBe(testResult)
})

test('test function declaration with params', () => {
    let test = 'test (a, b) { // {#}'
    let testResult = 'test (a, b) {\nconsole.log(a, b)'
    expect(loggerParser.parseLogger(test, {hook: '#'})).toBe(testResult)
})
Download .txt
gitextract_mhxvg_ky/

├── .babelrc
├── .gitignore
├── .npmignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── example/
│   ├── example.js
│   ├── index.html
│   ├── main.js
│   ├── source.vue
│   └── webpack.config.js
├── index.js
├── lib/
│   ├── constant/
│   │   ├── logger-types.js
│   │   └── options.js
│   ├── in-js.js
│   ├── index.js
│   └── utils/
│       ├── logger-note-judge.js
│       ├── logger-parser.js
│       └── logger-type-judge.js
├── package.json
└── test/
    ├── loader-type-judge.test.js
    └── logger-parser.test.js
Download .txt
SYMBOL INDEX (3 symbols across 1 files)

FILE: example/example.js
  function Example (line 1) | function Example (test) { // {#} -sign -w -t Example
  function testFunc (line 11) | function testFunc (form) {
  function testFuncCallback (line 15) | function testFuncCallback (cb) {
Condensed preview — 23 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (58K chars).
[
  {
    "path": ".babelrc",
    "chars": 83,
    "preview": "{\r\n    \"presets\": [\"env\"],\r\n    \"plugins\": [\r\n        \"transform-runtime\"\r\n    ]\r\n}"
  },
  {
    "path": ".gitignore",
    "chars": 44,
    "preview": ".DS_Store\r\nnode_modules\r\n*.log\r\nexample/dist"
  },
  {
    "path": ".npmignore",
    "chars": 26,
    "preview": "test\r\nexample\r\nyarn.lock\r\n"
  },
  {
    "path": ".travis.yml",
    "chars": 36,
    "preview": "language: node_js\r\nnode_js:\r\n  - \"8\""
  },
  {
    "path": "CHANGELOG.md",
    "chars": 20572,
    "preview": "<a name=\"0.9.0\"></a>\n# 0.9.0 (2018-05-09)\n\n\n### Bug Fixes\n\n* fix bug 'loaderContext is not defined' ([a03dacf](https://g"
  },
  {
    "path": "LICENSE",
    "chars": 1059,
    "preview": "MIT License\n\nCopyright (c) 2018 杨鑫\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this"
  },
  {
    "path": "README.md",
    "chars": 4749,
    "preview": "# vue-pretty-logger\n\n[![Scrutinizer Build](https://img.shields.io/npm/v/vue-pretty-logger.svg?style=for-the-badge)](http"
  },
  {
    "path": "example/example.js",
    "chars": 371,
    "preview": "function Example (test) { // {#} -sign -w -t Example\r\n    let a = 123\r\n\r\n    testFunc(a) // {#} -sign -i -from -time -pr"
  },
  {
    "path": "example/index.html",
    "chars": 137,
    "preview": "<style>\r\n    html, body {\r\n        margin: 0; padding: 0;\r\n    }\r\n</style>\r\n<div id=\"app\"></div>\r\n<script src=\"/dist/bun"
  },
  {
    "path": "example/main.js",
    "chars": 177,
    "preview": "import Vue from 'vue'\r\nimport Foo from './source.vue'\r\nimport Example from './example.js'\r\n\r\nExample('I\\' a test str')\r\n"
  },
  {
    "path": "example/source.vue",
    "chars": 4687,
    "preview": "<template>\r\n    <div class=\"container\">\r\n        <header class=\"header\">Vue-Pretty-Logger</header>\r\n        <section cla"
  },
  {
    "path": "example/webpack.config.js",
    "chars": 1282,
    "preview": "const path = require('path')\r\nconst VueLoaderPlugin = require('vue-loader/lib/plugin.js')\r\n\r\nmodule.exports = {\r\n    mod"
  },
  {
    "path": "index.js",
    "chars": 60,
    "preview": "const loader = require('./loader')\n\nmodule.exports = loader\n"
  },
  {
    "path": "lib/constant/logger-types.js",
    "chars": 156,
    "preview": "module.exports = {\n    FUNCTION: 'FUNCTION',\n    FUNCTION_CALL: 'FUNCTION_CALL',\n    ASSIGNMENT: 'ASSIGNMENT',\n    FUNCT"
  },
  {
    "path": "lib/constant/options.js",
    "chars": 662,
    "preview": "module.exports = {\r\n    tag: '',\r\n    dev: true,\r\n    hook: '#',\r\n    tagStyle: '',\r\n\r\n    infoTag: 'INFO',\r\n    infoTag"
  },
  {
    "path": "lib/in-js.js",
    "chars": 1372,
    "preview": "// Vue-pretty-logger-loader\r\nconst loaderUtils = require('loader-utils')\r\nconst compiler = require('vue-template-compile"
  },
  {
    "path": "lib/index.js",
    "chars": 1332,
    "preview": "// Vue-pretty-logger-loader\nconst loaderUtils = require('loader-utils')\nconst compiler = require('vue-template-compiler'"
  },
  {
    "path": "lib/utils/logger-note-judge.js",
    "chars": 6812,
    "preview": "// logger-note-judge\nconst loggerNoteJudge = {\n    tagCommand: '-t',\n    signCommand: '-sign',\n    countCommand: '-count"
  },
  {
    "path": "lib/utils/logger-parser.js",
    "chars": 2113,
    "preview": "// logger-parser\nconst typeJudge = require('./logger-type-judge')\nconst noteJudge = require('./logger-note-judge')\nconst"
  },
  {
    "path": "lib/utils/logger-type-judge.js",
    "chars": 4324,
    "preview": "const loggerTypes = require('../constant/logger-types')\n\nconst assignmentTag = ['let', 'const', 'var']\n\nmodule.exports ="
  },
  {
    "path": "package.json",
    "chars": 1566,
    "preview": "{\n  \"name\": \"vue-pretty-logger\",\n  \"version\": \"0.9.0\",\n  \"author\": \"YangXin\",\n  \"description\": \"Pretty logger for Vue\",\n"
  },
  {
    "path": "test/loader-type-judge.test.js",
    "chars": 2444,
    "preview": "const loggerTypeJudge = require('../lib/utils/logger-type-judge')\r\n\r\ntest('test loggerTypeJudge assignment', () => {\r\n  "
  },
  {
    "path": "test/logger-parser.test.js",
    "chars": 695,
    "preview": "const loggerParser = require('../lib/utils/logger-parser')\r\n\r\ntest('test parse logger with normal', () => {\r\n    let tes"
  }
]

About this extraction

This page contains the full source code of the TaroXin/vue-pretty-logger GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 23 files (53.5 KB), approximately 15.1k tokens, and a symbol index with 3 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!