Skip to content

Conversation

@jiangpengcheng
Copy link
Member

@jiangpengcheng jiangpengcheng commented Oct 30, 2025

Make the python log config template more robust

It was using formatter_formatter for text format and formatter_json for json format, but when Rolling is enabled, it will use the formatter_formatter to get the formatter, regardless of the log format, and then cause an error:

Traceback (most recent call last):
  File "/pulsar/instances/python-instance/python_instance_main.py", line 318, in <module>
    main()
  File "/pulsar/instances/python-instance/python_instance_main.py", line 244, in main
    log.init_logger(logging_level, log_file, args.logging_config_file)
  File "/pulsar/instances/python-instance/log.py", line 91, in init_logger
    logging.config.fileConfig(logging_config_file)
  File "/usr/local/lib/python3.12/logging/config.py", line 91, in fileConfig
    handlers = _install_handlers(cp, formatters)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/logging/config.py", line 170, in _install_handlers
    h.setFormatter(formatters[fmt])
                   ~~~~~~~~~~^^^^^
KeyError: 'formatter'

Modifications

Describe the modifications you've done.

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Documentation

Check the box below.

Need to update docs?

  • doc-required

    (If you need help on updating docs, create a doc issue)

  • no-need-doc

    (Please explain why)

  • doc

    (If this PR contains doc changes)

@jiangpengcheng jiangpengcheng requested review from a team, freeznet and nlu90 as code owners October 30, 2025 03:11
@github-actions github-actions bot added the no-need-doc This pr does not need any document label Oct 30, 2025
@jiangpengcheng jiangpengcheng merged commit c3e95f9 into master Oct 31, 2025
14 checks passed
@jiangpengcheng jiangpengcheng deleted the fix_python_log_config branch October 31, 2025 01:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-need-doc This pr does not need any document

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants