MarcSchaetz / vuejs3-logger

Provides customizable logging functionality for Vue.js. Compatible with Vue3.
MIT License
9 stars 4 forks source link

Log from external function #3

Open xkubow opened 3 years ago

xkubow commented 3 years ago

Can't use logger outside vue. Could be provided correct type? Isn't the inject method the vue composition API?

export function logAxiosError(error: AxiosError): void { const logger = inject('vuejs3-logger') as Log; logger.error('AxiosError: ', error); }

whaliendev commented 3 years ago

Yes, I have the same issue. According to vue3 api refrence provide/inject:

provide and inject enables dependency injection. Both can only be called during setup() with a current active instance.

So, is there an elegant way to log from an external js file? for example, from a js file encapsulates axios requests.

whaliendev commented 3 years ago

Bro, you can check these two comments #1 comment and #2 comment for a solution under the current release. Hope these can help you, or maybe it's a little late.