Skip to content

feat(logger): support VSAG_LOG_LEVEL#2414

Merged
wxyucs merged 1 commit into
antgroup:mainfrom
wxyucs:codex/env-log-level
Jul 8, 2026
Merged

feat(logger): support VSAG_LOG_LEVEL#2414
wxyucs merged 1 commit into
antgroup:mainfrom
wxyucs:codex/env-log-level

Conversation

@wxyucs

@wxyucs wxyucs commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Change Type

  • Bug fix
  • New feature
  • Improvement/Refactor
  • Documentation
  • CI/Build/Infra

Linked Issue

Not applicable for kind/improvement; no issue was provided.

What Changed

  • Added VSAG_LOG_LEVEL parsing for the built-in DefaultLogger.
  • Supported values: trace, debug, info, warn/warning, error, and critical.
  • Invalid values are ignored so the existing default info level remains in effect.
  • Documented the environment variable in English and Chinese API resource docs.

Test Evidence

  • make fmt
  • make lint
  • make test
  • make cov, run tests, and collect coverage
  • Other (describe below)

Test details:

# TDD check before implementation: failed as expected
./build/tests/unittests "DefaultLogger uses VSAG_LOG_LEVEL"

clang-format-15 -i src/impl/logger/default_logger.cpp src/impl/logger/default_logger.h src/impl/logger/default_logger_test.cpp
cmake --build ./build --target unittests --parallel 96
./build/tests/unittests "DefaultLogger*"
# All tests passed (6 assertions in 5 test cases)

./build/tests/unittests "[ut][logger]"
# All tests passed (11 assertions in 7 test cases)

git diff --check

Compatibility Impact

  • API/ABI compatibility: no public API change.
  • Behavior changes: the built-in logger now reads VSAG_LOG_LEVEL when it is constructed; explicit SetLevel calls still override it.

Performance and Concurrency Impact

  • Performance impact: none expected; parsing happens once at logger construction.
  • Concurrency/thread-safety impact: none expected.

Documentation Impact

  • No docs update needed
  • Updated docs:
    • README.md
    • DEVELOPMENT.md
    • CONTRIBUTING.md
    • Other: docs/docs/en/src/api/resource.md, docs/docs/zh/src/api/resource.md

Risk and Rollback

  • Risk level: low
  • Rollback plan: revert this commit.

Checklist

  • I have linked the relevant issue (required for kind/bug and kind/feature; see "Linked Issue" above)
  • I have added/updated tests for new behavior or bug fixes
  • I have considered API compatibility impact
  • I have updated docs if behavior/workflow changed
  • My commit messages follow project conventions (Conventional Commits, optional [skip ci] prefix)

Copilot AI review requested due to automatic review settings July 3, 2026 08:47
@wxyucs wxyucs added kind/improvement Optimizations, UX polish, or minor improvements 性能优化、体验打磨或细节改良 version/1.0 labels Jul 3, 2026
@mergify mergify Bot added the module/docs label Jul 3, 2026
@mergify

mergify Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 2 merge protections satisfied — ready to merge.

Show 2 satisfied protections

🟢 Require kind label

  • label~=^kind/

🟢 Require version label

  • label~=^version/

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces the ability to configure the log level of the built-in logger using the VSAG_LOG_LEVEL environment variable, including updates to English and Chinese documentation, implementation of a case-insensitive log level parser, and comprehensive unit tests. The reviewer feedback suggests avoiding virtual function calls in the constructor by directly updating the atomic log level, adding a length guard to the parser to prevent unnecessary allocations, and supporting as well as documenting the "off" log level to completely disable logging.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread src/impl/logger/default_logger.cpp
Comment thread src/impl/logger/default_logger.cpp
Comment thread src/impl/logger/default_logger.cpp
Comment thread docs/docs/en/src/api/resource.md Outdated
Comment thread docs/docs/zh/src/api/resource.md Outdated

Copilot AI 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.

Pull request overview

Adds support for configuring the built-in vsag::DefaultLogger log level via a VSAG_LOG_LEVEL environment variable, and documents this behavior in the API “Resource” docs (EN/ZH). This fits into VSAG’s runtime configuration surface by allowing users to adjust default logging verbosity without changing code.

Changes:

  • Added VSAG_LOG_LEVEL parsing at DefaultLogger construction time with support for trace, debug, info, warn/warning, error, critical (invalid values are ignored).
  • Added unit tests covering env-driven level selection, alias handling, invalid input fallback, and explicit SetLevel override behavior.
  • Documented VSAG_LOG_LEVEL usage in English and Chinese API resource docs.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/impl/logger/default_logger.h Declares an explicit DefaultLogger() constructor to enable env-based initialization.
src/impl/logger/default_logger.cpp Implements VSAG_LOG_LEVEL parsing and applies the parsed level during logger construction.
src/impl/logger/default_logger_test.cpp Adds Catch2 tests and small RAII helpers for env/stream capture to validate new behavior.
docs/docs/en/src/api/resource.md Documents VSAG_LOG_LEVEL behavior and supported values (EN).
docs/docs/zh/src/api/resource.md Documents VSAG_LOG_LEVEL behavior and supported values (ZH).

Comment thread src/impl/logger/default_logger.cpp
Signed-off-by: Xiangyu Wang <wxy407827@antgroup.com>
Assisted-by: Codex:GPT-5
@wxyucs wxyucs force-pushed the codex/env-log-level branch from 21c2be6 to c0de6ba Compare July 3, 2026 12:01
@wxyucs

wxyucs commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator Author

/assign @wxyucs

@vsag-bot

vsag-bot commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

/label S-ready-to-merge
/waiting-on maintainer
/request-review @jiaweizone
/request-review @inabao

@LHT129 LHT129 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@mergify

mergify Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@wxyucs wxyucs merged commit eb60ce6 into antgroup:main Jul 8, 2026
20 checks passed
@wxyucs wxyucs deleted the codex/env-log-level branch July 8, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/improvement Optimizations, UX polish, or minor improvements 性能优化、体验打磨或细节改良 module/docs size/L version/1.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants