Add singleton support for Logger class#106
Conversation
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 Report
@@ 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
Continue to review full report at Codecov.
|
|
@tsingh2k15 Does this preserve the |
@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 |
|
I'm good to merge this once @vvmnnnkv approves. |
@vvmnnnkv I am following up on this, please let me know if you have questions. |
My attempt to contribute and help for #63
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.