Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: debug logging improvements #889

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

gmaclennan
Copy link
Member

Several improvements to debug logging, to improve our ability to parse the logs and gather useful information:

  • Fix a memory issue in the PeerSyncController logger, that was creating a new Debugger instance (by calling Logger.create()) each time anything was logged.
  • Fixed a memory issue in PeerSyncController which was adding a peer-remove event listener every time a core is replicated, and never removing the listener. This was solely for debugging. Now only adds the listener if debugging is enabled.
  • Log the namespace of cores that are replicated or unreplicated.
  • Change the function signatures in PeerSyncController and expose the CoreRecord of the creator core, to enable this namespace logging.
  • Removed unnecesary logging when handling discovery keys in PeerSyncController.
  • SyncApi: only log change of sync enabled state, rather than logging it on every state update.
  • SyncApi: Remove superflous logging for when cores are added (adding cores is logged by core manager).
  • Explicitly include the supports-color dev dependency, which debug uses if available to support more colors (it was using this anyway, as a transitive dependency included by an unrelated module, but this makes the dependency more explicit).
  • Remove unhelpful "No project settings" log in MapeoProject
  • Add logging to MapeoManager.#waitForInitialSync to show why sync is pending.
  • Configure the debug module to color debug lines according to the deviceId, rather than a different color for each namespace. Simplifies identifying which debug lines come from each peer in tests.
  • Logger.log is now an instance of debug.Debugger, with its properties such as Debugger.enabled. Before it was just a function that wrapped debug.Debugger.

@gmaclennan gmaclennan self-assigned this Oct 3, 2024
@awana-lockfile-bot
Copy link

package-lock.json changes

Click to toggle table visibility
Name Status Previous Current
supports-color UPDATED 7.2.0 9.4.0

@gmaclennan gmaclennan marked this pull request as ready for review October 3, 2024 13:29
Comment on lines +50 to +51
* @param {any} formatter
* @param {...any} args
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use the stronger types from before?

@gmaclennan gmaclennan merged commit 717b063 into main Oct 3, 2024
8 checks passed
@gmaclennan gmaclennan deleted the chore/debug-logging-improvements branch October 3, 2024 13:34
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.

2 participants