Skip to content

add ensure_ascii param - #188

Merged
xrmx merged 4 commits into
elastic:mainfrom
k8scat:main
Nov 24, 2025
Merged

add ensure_ascii param#188
xrmx merged 4 commits into
elastic:mainfrom
k8scat:main

Conversation

@k8scat

@k8scat k8scat commented Nov 14, 2025

Copy link
Copy Markdown
Contributor

feat: #170

@cla-checker-service

cla-checker-service Bot commented Nov 14, 2025

Copy link
Copy Markdown

💚 CLA has been signed

@github-actions

Copy link
Copy Markdown

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@k8scat

k8scat commented Nov 14, 2025

Copy link
Copy Markdown
Contributor Author

run docs-build

@xrmx xrmx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR, haven't looked closely at the code but this needs some tests and some docs update in docs/setup.asciidoc in order to be merged.

…Formatter` and `StructlogFormatter` to control non-ASCII character escaping. Update documentation and add tests to verify behavior for different `ensure_ascii` values.
@github-actions

github-actions Bot commented Nov 19, 2025

Copy link
Copy Markdown

🔍 Preview links for changed docs

@k8scat

k8scat commented Nov 19, 2025

Copy link
Copy Markdown
Contributor Author

Thanks for the PR, haven't looked closely at the code but this needs some tests and some docs update in docs/setup.asciidoc in order to be merged.

Thanks for the feedback! I've addressed both points:

Tests Added

I've added comprehensive test coverage for the ensure_ascii parameter:

For StdlibFormatter (5 new tests in tests/test_stdlib_formatter.py):

  • Tests for default behavior (ensure_ascii=True)
  • Tests for explicit True/False values
  • Tests with emojis and Unicode characters (Chinese, etc.)
  • Tests with extra fields containing non-ASCII characters

For StructlogFormatter (5 new tests in tests/test_structlog_formatter.py):

  • Similar comprehensive coverage for the structlog formatter
  • All tests verify both the JSON output format and correct parsing

All tests verify that:

  • Non-ASCII characters are properly escaped when ensure_ascii=True (default)
  • Non-ASCII characters are preserved when ensure_ascii=False
  • The output is always valid JSON

Documentation Updated

I've added documentation to docs/reference/installation.md (note: this project uses markdown docs rather than asciidoc). The documentation includes:

  • A new section "Controlling ASCII encoding" for StdlibFormatter
  • A new section "Controlling ASCII encoding for Structlog" for StructlogFormatter
  • Code examples showing both default and custom behavior
  • Explanation of use cases for internationalized applications

Please let me know if you'd like any changes or have additional feedback!

basepi
basepi previously approved these changes Nov 21, 2025

@basepi basepi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great. Thanks for adding docs and tests!

@k8scat

k8scat commented Nov 24, 2025

Copy link
Copy Markdown
Contributor Author

Looks great. Thanks for adding docs and tests!

Thanks! I've also reformatted the code to ensure consistency. The changes are now ready for review.

@xrmx
xrmx merged commit 908d4e4 into elastic:main Nov 24, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants