Debug: How should I run debug in vue.js project?

Created on 24 Apr 2019  路  4Comments  路  Source: visionmedia/debug

my vue component:

<script>
import debug from 'debug'

const log = debug('app:logging')

export default {
...
  created(){
    log('testing logging');
  }
...
}
<script>
  • did run the project in VS Code powershell:$env:DEBUG='app:*'; npm run serve
  • did try cmder with set DEBUG=app:* & npm run serve
  • did try set DEBUG in .env file got message [dotenv][DEBUG] "DEBUG" is already defined in "process.env" and will not be overwritten

What should I do to get this working corectly? I would like to see the message testing logging in console.

Most helpful comment

We use this in our Vue projects, in whatever js file is your main entry point

import debug from 'debug'
const log = debug('app')

if (config.get('isLocal')) {
  debug.enable('app*,store*,module*,utility*')
  log('Initialized App')
}

The if statement is optional, we just only run debug if our config is set to dev mode.

All 4 comments

I'm new to web developing. I'm using webpack. I set the localstorage in code and chcek the DevTools. But still dont see the message. Could you point me where/how to set the localstorage correcly so it is working.

We use this in our Vue projects, in whatever js file is your main entry point

import debug from 'debug'
const log = debug('app')

if (config.get('isLocal')) {
  debug.enable('app*,store*,module*,utility*')
  log('Initialized App')
}

The if statement is optional, we just only run debug if our config is set to dev mode.

Just set debug item of localstorage and refresh your page, for example, see the following snapshot.

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adamcohenrose picture adamcohenrose  路  3Comments

anishkny picture anishkny  路  6Comments

ArvoGuo picture ArvoGuo  路  5Comments

kopax picture kopax  路  4Comments

roccomuso picture roccomuso  路  8Comments