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: improve websocket logs #416

Open
wants to merge 1 commit into
base: old-dev
Choose a base branch
from

Conversation

luislhl
Copy link
Contributor

@luislhl luislhl commented Sep 15, 2022

Acceptance Criteria

  • Log when the websocket connection is established

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

@@ -186,6 +186,8 @@ abstract class BaseWebSocket extends EventEmitter {
this.heartbeat = setInterval(() => {
this.sendPing();
}, this.heartbeatInterval);

console.info('Websocket connection opened.');
Copy link
Contributor

Choose a reason for hiding this comment

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

I know we are already logging the websocket ping timeout, but I don't like the idea of having logs on the lib, it pollutes the sdout of the clients using it

Maybe we should just emit an event here and log on the client

Copy link
Contributor

Choose a reason for hiding this comment

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

If we decide to emit an event to log something, I would suggest to create an util logger that centralizes all the logging on the lib and implements this event emit with the common interface of log, warn, error, etc.

That way we can have a familiar logging structure within the lib, just as if it was a common application, and have the centralized logger deal with the events. This would also make it easier for future logging configurations.

@codecov
Copy link

codecov bot commented Sep 15, 2022

Codecov Report

Merging #416 (3fad653) into dev (62c1cca) will increase coverage by 0.00%.
The diff coverage is 50.00%.

@@           Coverage Diff           @@
##              dev     #416   +/-   ##
=======================================
  Coverage   56.68%   56.68%           
=======================================
  Files          55       55           
  Lines        4603     4604    +1     
  Branches      879      879           
=======================================
+ Hits         2609     2610    +1     
  Misses       1804     1804           
  Partials      190      190           
Impacted Files Coverage Δ
src/websocket/base.ts 82.69% <50.00%> (+0.16%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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.

3 participants