-
-
Notifications
You must be signed in to change notification settings - Fork 775
Warn on service startup if a non utf-8 encoding is used #5182
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
128d082
Update service setup code so also print used locale and fs encoding.
Kami 68fbfc6
Update affected tests, add test for verifying service startup messages.
Kami a461311
Update service bootstrap / start up code to log a warning on non-utf-8
Kami b8c2c89
Add a test case for it.
Kami b55682f
Add changelog entry.
Kami 697a50a
Add bug fix for LoggingStream stderr wrapper which would result in
Kami 99ae8b0
Update affected tests.
Kami 84ad5fa
Apply suggestions from code review
Kami 12473d5
Uncomment out the test, add additional asserts.
Kami 19b1ba2
Merge branch 'master' into non_utf8_locale_warn
blag 651f64d
Merge branch 'master' into non_utf8_locale_warn
Kami b431d74
Cherry pick changelog entries from #5192 and sync it up.
Kami 63522e3
Merge branch 'non_utf8_locale_warn' of github.com:StackStorm/st2 into…
Kami File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # Copyright 2020 The StackStorm Authors. | ||
| # Copyright 2019 Extreme Networks, Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """ | ||
| This file is used to test edge case with logging unicode data. | ||
| """ | ||
|
|
||
| from __future__ import absolute_import | ||
|
|
||
| import os | ||
| import sys | ||
|
|
||
| from oslo_config import cfg | ||
|
|
||
| BASE_DIR = os.path.dirname(os.path.abspath(__file__)) | ||
|
|
||
| ST2ACTIONS_PATH = os.path.join(BASE_DIR, "../../../st2actions") | ||
| ST2COMMON_PATH = os.path.join(BASE_DIR, "../../") | ||
| ST2TESTS_PATH = os.path.join(BASE_DIR, "../../../st2tests") | ||
|
|
||
| # Ensure st2actions is in PYTHONPATH. | ||
| # This is needed since this script is spawned from inside integration tests | ||
| sys.path.append(ST2ACTIONS_PATH) | ||
| sys.path.append(ST2COMMON_PATH) | ||
| sys.path.append(ST2TESTS_PATH) | ||
|
|
||
| from st2actions.notifier import config | ||
| from st2common import log as logging | ||
| from st2common.service_setup import setup as common_setup | ||
|
|
||
| FIXTURES_DIR = os.path.join(ST2TESTS_PATH, "st2tests/fixtures") | ||
| ST2_CONFIG_DEBUG_LL_PATH = os.path.join( | ||
| FIXTURES_DIR, "conf/st2.tests.api.debug_log_level.conf" | ||
| ) | ||
|
|
||
| LOG = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def main(): | ||
| cfg.CONF.set_override("debug", True) | ||
| common_setup( | ||
| service="test", | ||
| config=config, | ||
| setup_db=False, | ||
| run_migrations=False, | ||
| register_runners=False, | ||
| register_internal_trigger_types=False, | ||
| register_mq_exchanges=False, | ||
| register_signal_handlers=False, | ||
| service_registry=False, | ||
| config_args=["--config-file", ST2_CONFIG_DEBUG_LL_PATH], | ||
| ) | ||
|
|
||
| LOG.info("Test info message 1") | ||
| LOG.debug("Test debug message 1") | ||
|
|
||
| # 1. Actual unicode sequence | ||
| LOG.info("Test info message with unicode 1 - 好好好") | ||
| LOG.debug("Test debug message with unicode 1 - 好好好") | ||
|
|
||
| # 2. Ascii escape sequence | ||
| LOG.info( | ||
| "Test info message with unicode 1 - " | ||
| + "好好好".encode("ascii", "backslashreplace").decode("ascii", "backslashreplace") | ||
| ) | ||
| LOG.debug( | ||
| "Test debug message with unicode 1 - " | ||
| + "好好好".encode("ascii", "backslashreplace").decode("ascii", "backslashreplace") | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.