Fix up/down command console output when logger replaces it.#365
Merged
seppevs merged 1 commit intoseppevs:masterfrom Jan 29, 2025
Merged
Fix up/down command console output when logger replaces it.#365seppevs merged 1 commit intoseppevs:masterfrom
seppevs merged 1 commit intoseppevs:masterfrom
Conversation
|
I've included this PR in https://github.com/theogravity/migrate-mongo-alt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello, this is tiny PR that fixes pretty unique issue.
I am replacing console with logger function, so that when I run
upordowncommands, the console output is logged using logger configuration (I am using log4js).My config looks like:
This all works fine, I am getting STDOUT output similar to:
Log4jsis configured to usestdoutandfileappenders. The problem is that command output goes to standard output, but does not go to the file for unknown reason. Presumably this is related to the fact that process ends synchronously withconsole.logcall in the code, and internally in node file writing stops too early, just guessing.So, solution is simple. When I defer
process.exit(0);to the next tick by moving it in separatethenin the chain, my issue gets resolved. In fact, you are using the same pattern forstatuscommand, which I am not interested in logging, but noticed it logs correctly when I remove command condition in the config file.Please consider accepting this PR 😃
Checklist
npm testpasses and has 100% coverage