Fix console and file logging on Windows #34895
Merged
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.
What does this PR do?
On Windows, only the main process properly logged to console and to
file. Things worked on other OSes due to the logging configuration
being propagated via fork, something that won't work on Windows.
The new strategy for Windows is if multiprocessing mode is used,
all console and file logging will be performed through the
Multiprocessing Logging Listener except for the main process. The
main process does not send stuff to the Multiprocessing Logging Listener.
Hence the main process will still configure file and console logging
separately from the MP Logging Listener.
If multiprocessing mode is off, then logging will be done as before
(which should be ok since there is only one process).
salt/utils/parsers.py:
log.setup_logfile_logger
andlog.setup_console_logger
. Thisfunctionality is run before
self._setup_mp_logging_listener
so thatthe options passed to the MP Logging Listener are appropriate for direct
use in the functions that setup the console and file logging in the
MP Logging Listener process.
cli/daemons.py
to be able to run it before creating the MP LoggingListener. Its original place in
cli/daemons.py
would run after theMP Logging Listener is created.
salt/log/setup.py:
setup_console_logger
andsetup_logfile_logger
using theappropriate options if running on Windows.
salt/minion.py:
logging on Windows multiprocessing mode due to the MP Logging
Listener taking care of that on Windows.
salt/cli/daemons.py:
utils/parsers.py
.Tests created?
No
Signed-off-by: Sergey Kizunov sergey.kizunov@ni.com