Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix console and file logging on Windows #34895

Merged
merged 1 commit into from
Jul 22, 2016
Merged

Conversation

skizunov
Copy link
Contributor

@skizunov skizunov commented Jul 22, 2016

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:

  • Broke apart the logic that figures out the input options for
    log.setup_logfile_logger and log.setup_console_logger. This
    functionality is run before self._setup_mp_logging_listener so that
    the 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.
  • Moved the logic that verifies the path for the log file from
    cli/daemons.py to be able to run it before creating the MP Logging
    Listener. Its original place in cli/daemons.py would run after the
    MP Logging Listener is created.

salt/log/setup.py:

  • Invoke setup_console_logger and setup_logfile_logger using the
    appropriate options if running on Windows.

salt/minion.py:

  • No longer need to invoke the functions to setup the console and file
    logging on Windows multiprocessing mode due to the MP Logging
    Listener taking care of that on Windows.

salt/cli/daemons.py:

  • Moved the logic that verifies the path for the log file to
    utils/parsers.py.

Tests created?

No

Signed-off-by: Sergey Kizunov sergey.kizunov@ni.com

On Windows, only the main process properly logged to console and to
file. Things worked on other OSes due to the logging configuration
being propogated 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:
- Broke apart the logic that figures out the input options for
`log.setup_logfile_logger` and `log.setup_console_logger`. This
functionality is run before `self._setup_mp_logging_listener` so that
the 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.
- Moved the logic that verifies the path for the log file from
`cli/daemons.py` to be able to run it before creating the MP Logging
Listener. Its original place in `cli/daemons.py` would run after the
MP Logging Listener is created.

salt/log/setup.py:
- Invoke `setup_console_logger` and `setup_logfile_logger` using the
appropriate options if running on Windows.

salt/minion.py:
- No longer need to invoke the functions to setup the console and file
logging on Windows multiprocessing mode due to the MP Logging
Listener taking care of that on Windows.

salt/cli/daemons.py:
- Moved the logic that verifies the path for the log file to
`utils/parsers.py`.

Signed-off-by: Sergey Kizunov <sergey.kizunov@ni.com>
@cachedout cachedout merged commit 365fca3 into saltstack:develop Jul 22, 2016
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.

None yet

2 participants