npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-pretty-logger-stzhang

v0.0.8

Published

Pretty logger for Vue

Downloads

4

Readme

vue-pretty-logger

Scrutinizer Build Scrutinizer Build npm

README for Chinese

Table of content

What is Vue pretty logger loader ?

vue-pretty-logger-stzhang is a loader for webpack, you can use it in your .vue file

<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?

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

Install

npm install vue-pretty-logger-stzhang -D
// or
yarn add --dev vue-pretty-logger-stzhang

in your webpack config file

NOTE: vue-pretty-logger-stzhang must be executed prior to vue-loader, Putting it at the bottom of the list of loaders is the best choice

...
module: {
  rules: [
    {
      test: /\.vue$/,
      use: [
        {
          loader: 'vue-loader'
        },
        {
          loader: 'vue-pretty-logger-stzhang',
          options: {
            preserve: true,
            tag: '****'
          }
        }
      ]
    }
  ]
}
...

Usage

in your vue file

<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>

Example

Example can be found in example/

Options

  • preserve Force to perserve console.log() in production environment default: false
  • 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

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
  • -serialize Utilize JSON.stringify(obj, null, 2) to log an object or array.

Change Log

  • V0.0.6 Use localStorage.DEBUG to filter the logs.
  1. localStorage.DEBUG string is converted to a RegExp object.
  2. Utilize the RegExp object to filter the comment tag per log.
// add support for js files

{
    test: /\.js$/,
    use: ['babel-loader', 'vue-pretty-logger/lib/in-js'],
    exclude: /node_modules/
}
// 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}`)
// Add support for await statements, consistent with function call

await test() // {#} -e -sign -time
// equals: const result = await test(); console.error(`result: ${result}`)
// 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}`)
})
fix bug: Can not read property 'content' of null