Skip to content

Conversation

@MarcelRobitaille
Copy link
Collaborator

Fixes #1275

Add a logging library and make enabling/disabling the logging and changing the log level configurable from localStorage. This way, we can instruct users to enable logging even before loading any of our JavaScript. This is very useful to troubleshoot issues that prevent our page from loading properly. The buttons to enable logging would obviously not work in this case.

To enable logging, a user only has to run the following before loading the app/refreshing the page:

localStorage.setItem('COOKBOOK_LOGGING_ENABLED', 'true')

This will automatically be reset after 30 minutes so verbose logging is not enabled permanently for the user.

The log level is also configurable. For example:

localStorage.setItem('COOKBOOK_LOGGING_LEVEL', 'debug')

I added some logs throughout the app, but I suspect we will flush this out as required. I also added some logs specific to troubleshooting #1257.

To add a log inside a Vue component, you only have to do:

this.$log.debug('message')

To add a log outside a view component, you can do:

Vue.$log.debug('message')

Signed-off-by: Marcel Robitaille <[email protected]>
Make enabling/disabling the logging and changing the log level
configurable from localStorage. This way, we can instruct users to
enable logging even before loading any of our JavaScript. This is very
useful to troubleshoot issues that prevent our page from loading
properly. The buttons to enable logging would obviously not work in
this case.

Signed-off-by: Marcel Robitaille <[email protected]>
Signed-off-by: Marcel Robitaille <[email protected]>
Signed-off-by: Marcel Robitaille <[email protected]>
@github-actions
Copy link

github-actions bot commented Oct 24, 2022

Test Results

     15 files     675 suites   3m 10s ⏱️
   493 tests    493 ✔️ 0 💤 0
2 465 runs  2 465 ✔️ 0 💤 0

Results for commit 484c903.

♻️ This comment has been updated with latest results.

@christianlupus
Copy link
Collaborator

christianlupus commented Oct 24, 2022

If possible please fix the issues with prettier and add a short section to the dev documentation on how to enable the logger.

I have not tested the code though.

Copy link
Collaborator

@christianlupus christianlupus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add logging to diagnose bugs in production

2 participants