Skip to content

Add singleton support for Logger class#106

Merged
vvmnnnkv merged 7 commits intoOpenMined:masterfrom
tsingh2k15:master
Mar 19, 2020
Merged

Add singleton support for Logger class#106
vvmnnnkv merged 7 commits intoOpenMined:masterfrom
tsingh2k15:master

Conversation

@tsingh2k15
Copy link
Contributor

@tsingh2k15 tsingh2k15 commented Mar 1, 2020

My attempt to contribute and help for #63

  • Modify Logger class such that a single instance can be reused across app.
  • Update unit tests impacted by this change.
  • Fix failing tests due to incorrect protobuf objects used in source code. {Ignore this, seems already fixed in master when I rebased)

Note: I did not freeze Logger instance because it is required to be
spied in jest unit tests. Freezing it would have not let it be spied by
jest mocks on log function. This change should allow reuse of a single
logger instance but improper use of logger inside source code can still
allow the verbose setting to be misused.

Modify Logger class such that a single instance can be reused acrss app.
Update unit tests impacted by this change.
Fix failing tests due to incorrect protobuf objects used in source code.

Note: I did not freeze Logger instance becasue it is required to be
spied in jest unit tests. Freezing it would have not let it be spied by
jest mocks on log function. TThis change should allow reuse of a single
logger instance but improper use of logger inside source code can still
allow the verbose setting to be misused.
@codecov
Copy link

codecov bot commented Mar 1, 2020

Codecov Report

Merging #106 into master will increase coverage by 0.20%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #106      +/-   ##
==========================================
+ Coverage   70.94%   71.15%   +0.20%     
==========================================
  Files          21       21              
  Lines         716      721       +5     
  Branches       94       95       +1     
==========================================
+ Hits          508      513       +5     
  Misses        184      184              
  Partials       24       24              
Impacted Files Coverage Δ
src/syft.js 15.09% <ø> (ø)
src/_helpers.js 95.45% <100.00%> (+0.21%) ⬆️
src/logger.js 100.00% <100.00%> (ø)
src/sockets.js 100.00% <100.00%> (ø)
src/types/message.js 83.60% <100.00%> (+0.27%) ⬆️
src/webrtc.js 90.66% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0d68026...7e161a8. Read the comment docs.

@cereallarceny
Copy link
Member

@tsingh2k15 Does this preserve the verbose setting originally set in the main Syft class? You should be able to set verbose: true and get logs or verbose: false and not get them... all within the main new syft() call. Can you confirm this and I'll merge?

@tsingh2k15
Copy link
Contributor Author

@tsingh2k15 Does this preserve the verbose setting originally set in the main Syft class? You should be able to set verbose: true and get logs or verbose: false and not get them... all within the main new syft() call. Can you confirm this and I'll merge?

@cereallarceny Sure, I will look into it and get back to you.

@tsingh2k15
Copy link
Contributor Author

@tsingh2k15 Does this preserve the verbose setting originally set in the main Syft class? You should be able to set verbose: true and get logs or verbose: false and not get them... all within the main new syft() call. Can you confirm this and I'll merge?

@cereallarceny Sure, I will look into it and get back to you.

@cereallarceny I added unit test to validate singleton behavior. It works as expected. Let me know your thoughts. 7925f0f

@cereallarceny cereallarceny requested a review from vvmnnnkv March 9, 2020 11:26
@cereallarceny
Copy link
Member

I'm good to merge this once @vvmnnnkv approves.

@tsingh2k15
Copy link
Contributor Author

I'm good to merge this once @vvmnnnkv approves.

@vvmnnnkv Can you please review ? There were some merge conflicts I have resolved, but please let me know if I may have missed something while resolving merge conflicts. Thanks!

@tsingh2k15
Copy link
Contributor Author

tsingh2k15 commented Mar 18, 2020

I'm good to merge this once @vvmnnnkv approves.

@vvmnnnkv Can you please review ? There were some merge conflicts I have resolved, but please let me know if I may have missed something while resolving merge conflicts. Thanks!

@vvmnnnkv I am following up on this, please let me know if you have questions.

Copy link
Member

@vvmnnnkv vvmnnnkv left a comment

Choose a reason for hiding this comment

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

Looks good, thanks! :)

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