question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not mounting properly?

See original GitHub issue

I was looking for a nuxt logger and came across this and had high hopes. I added everything to the nuxt.config as described, but for what ever reason I keep getting ‘Cannot read property ‘debug’ of undefined’

Ive tried using this in middleware using

export default function({store, app, redirect }) {
     if(notAuthenticated) {
         app.$log.error('User is not authenticated!')
         redirect('/auth')
      }
  }

I’ve tried using this in the vuex store using this.$log.debug('checking authentication')

Ive tried using this in a plugin using

import Vue from 'vue'

Vue.$log.debug('Setting theme to be...')

Nothing seems to work and it keeps acting as if its not mounted. Id really like to use this. What can i do to get this to work?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
jameshhoodcommented, Oct 1, 2018

so I made a plugin called logger.js with the following code

import Vue from 'vue'
import VueLogger from 'vuejs-logger'

const options = {
  isEnabled: true,
  logLevel: process.env.logLevel,
  stringifyArguments: false,
  showLogLevel: true,
  showMethodName: true,
  separator: '|',
  showConsoleColors: true
}
Vue.use(VueLogger, options)
export default ({
  app,
  store
}, inject) => {
  console.debug('Initializing Logger', options)
  VueLogger.install(Vue, options)
  app['$log'] = Vue.$log
  store['$log'] = Vue.$log
}

Two things to note here

  1. for options, I created an environment variable to be defaulted by the nuxt config, or say passed in by a PM2 config to set the logLevel. I default my nuxt config to ‘error’ and then have my dev command inside my package.json file pass ‘debug’ so when im running in dev mode it will always show debug output and when i run production it will be at error.
  2. For the logger to be accessible in other parts of the app outside of the standard vue (ie. app and store), i had to manually inject the logger into it. Its not a perfect solution but it allows me to use the logger inside the vuex store and during asyncData calls

Hope this helps

1reaction
homerjamcommented, Oct 1, 2018

Awesome, thank you!

On Mon, 1 Oct 2018, 20:37 James Hood, notifications@github.com wrote:

so I made a plugin called logger.js with the following code

import Vue from ‘vue’ import VueLogger from ‘vuejs-logger’

const options = { isEnabled: true, logLevel: process.env.logLevel, stringifyArguments: false, showLogLevel: true, showMethodName: true, separator: ‘|’, showConsoleColors: true } Vue.use(VueLogger, options) export default ({ app, store }, inject) => { console.debug(‘Initializing Logger’, options) VueLogger.install(Vue, options) app[‘$log’] = Vue.$log store[‘$log’] = Vue.$log }

Two things to note here

  1. for options, I created an environment variable to be defaulted by the nuxt config, or say passed in by a PM2 config to set the logLevel. I default my nuxt config to ‘error’ and then have my dev command inside my package.json file pass ‘debug’ so when im running in dev mode it will always show debug output and when i run production it will be at error.
  2. For the logger to be accessible in other parts of the app outside of the standard vue (ie. app and store), i had to manually inject the logger into it. Its not a perfect solution but it allows me to use the logger inside the vuex store and during asyncData calls

Hope this helps

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/justinkames/vuejs-logger/issues/21#issuecomment-426035589, or mute the thread https://github.com/notifications/unsubscribe-auth/ABAcGds2gWIXgHDyDXuyG0NkrHhTUpFhks5ugm76gaJpZM4VtZtn .

Read more comments on GitHub >

github_iconTop Results From Across the Web

External Hard Drive Not Mounting Mac? Fix It without Data Loss
Method 1: Restart your Mac and reconnect the drive · Method 2: Check Mac's drive display settings · Method 3: Force mount the...
Read more >
External Hard Drive Is Not Mounting on a Mac: 6 Methods to Fix
To access any drive through a computer, it needs to be properly mounted. By default, this process should happen in the background.
Read more >
How to Fix: External Drive Not Mounting on Mac - Disk Drill
Fix #2: Remount External Disk in Disk Utility · Start Disk Utility · Select the disk drive if you see it in the...
Read more >
External Hard Drive Not Mounting on Mac? Your Fixes Are Here
External hard drive not mounting on Mac may result in access denied, disk not showing/not recognized, etc., errors. This page lists the causes ......
Read more >
External Hard Drive not Mounting | Apple Developer Forums
Similar issue with my Western Digital external USB drives. None mount, but they are also not seen by Disk Utility. They do show...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found