vuestorefront / vue-storefront-api

Vue.js storefront for Magento2 (and not only) - data backend
https://www.vuestorefront.io
MIT License
348 stars 338 forks source link

[FEATURE] Use a Logger to replace console logs #570

Open rain2o opened 3 years ago

rain2o commented 3 years ago

I don't know if this repo is still accepting feature requests, or if it will ultimately be replaced by the new Storefront API, but as we're still using this one I wanted to present this idea here.

It would be very useful to add a custom Logger to be used throughout the code when logging stuff, which can have configurable controls for things like what level (if any) to log in Production. Vue Storefront has something like this already, so it should be somewhat translatable.

As a note, we recently discovered that vuestorefront-api is logging a lot of info, including the JSON encoded order data when placing an order, even in production. This was a security and privacy concern, so for now we have just removed all of these console.logs from the core code. In the short-term, something to easily configure this would be ideal, allowing us to basically disable all of these logs in a production environment.

In the long-term, it could be nice to have the option to use our own logger. Like how we now have the ability to set our own Image or Product processors for example. In our specific situation, we need to implement winston logger with a specific format so that it can be synchronized with a Kibana instance where we handle all of our log files internally. Being able to set a logger processor in the config like we can for products would make this a nice and easy change, and would allow us to set our own formatting, configuration options, etc...