Create global logger service for frontend #669
AllanOricil
started this conversation in
Ideas
Replies: 1 comment
-
@AllanOricil as far as I'm aware, the existing approach isn't very resource-intensive (it's a very small JS class), so I don't think this is currently causing any major issues with page loads & memory usage. Switching to a global component would also lead to other issues:
At least for now, I think the current approach is better than moving to a global component. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The current logger for lwc creates several logger objects instead of a single global object. If used in all components in a page, it can slow down page loads, and use unnecessary memory.
To solve this potential issue I thought that the lwc logger can be exposed as a global service component that listens to events from other components within the same page. It would behave like a global object. Developers would drag and drop this service component in the pages where they want to gather logs from. Then the
createLogger
implementation would return an object that uses the global service, if one is available in the page.this.logger.saveLog()
would be handled in the global servicecomponents are responsible for emitting log events
global service is responsible for processing and storing logs
Beta Was this translation helpful? Give feedback.
All reactions