Skip to content

[enhancement]Emmit pause event for node js when buffer is full#938

Merged
nomiddlename merged 3 commits intolog4js-node:masterfrom
shayantabatabaee:master
Nov 14, 2019
Merged

[enhancement]Emmit pause event for node js when buffer is full#938
nomiddlename merged 3 commits intolog4js-node:masterfrom
shayantabatabaee:master

Conversation

@shayantabatabaee
Copy link
Copy Markdown
Contributor

@shayantabatabaee shayantabatabaee commented Sep 8, 2019

Hi,

I made some change in file.js module, so when the buffer is full the 'pause' event will emit, and after now we can listen to this event. When this event is emitted we can stop logging or maybe send 'server too busy' response and wait till the drain event emitted. With these changes logger will not stop and just an event emitted, and this is possible if someone want to continue logging.

@nomiddlename
Copy link
Copy Markdown
Collaborator

Thanks for this, could you add a test that covers the change please?

@shayantabatabaee
Copy link
Copy Markdown
Contributor Author

Yes, I’ll add the test as soon as possible.

@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 10, 2019

Codecov Report

Merging #938 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #938      +/-   ##
==========================================
+ Coverage    98.6%   98.61%   +<.01%     
==========================================
  Files          25       25              
  Lines        1006     1009       +3     
==========================================
+ Hits          992      995       +3     
  Misses         14       14
Impacted Files Coverage Δ
lib/appenders/file.js 100% <100%> (ø) ⬆️

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 dc5bcf7...1a42018. Read the comment docs.

@shayantabatabaee
Copy link
Copy Markdown
Contributor Author

@nomiddlename I've added test for this situation.

Copy link
Copy Markdown
Collaborator

@nomiddlename nomiddlename left a comment

Choose a reason for hiding this comment

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

Sorry for not getting back to you sooner, I completely missed your updates. Thanks for working on this. I'm wondering if we should namespace the event that gets emitted (e.g. "log4js:pause" instead of just "pause") to avoid clashes. This event will work fine for simple logging cases, I think, but if you have a more complicated set up (multiple appenders, categories) then a user might need to know which appender is causing the event. That way they could pause the logging that goes to a file, but continue sending logs over the network, for example. What do you think?

@shayantabatabaee
Copy link
Copy Markdown
Contributor Author

thanks @nomiddlename for response, your are right I'will add the namespace to event.
For the second problem that you mentioned this event just emit if user get buffer more than it's allowed and this is just for writing to file, no matter how many files to write. I think when the user receives this event can decide to stop logging to file but continue to send over the network or even write in console. I mean this event only emit while writing to files and we can add this note to documents

@nomiddlename nomiddlename added this to the 6.1.0 milestone Nov 14, 2019
@nomiddlename
Copy link
Copy Markdown
Collaborator

Yep, I agree - let's start with this, and see if it's an approach that works for people. I'll create a couple of extra github issues to add documentation and also make the same changes in the dateFile appender. Once those are done, I'll push it out to NPM.

@nomiddlename
Copy link
Copy Markdown
Collaborator

To be clear, I don't expect you to work on those two extra issues - I just created them so that I can track what else needs to be done before I can release the change. If you want to work on them, that's awesome, but you don't have to. I'll work on them as I get time.

@nomiddlename nomiddlename merged commit 5c67e4a into log4js-node:master Nov 14, 2019
@nomiddlename
Copy link
Copy Markdown
Collaborator

Published to npm in [email protected]

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