Repository navigation
Conversation
set_log_hook always installed its sink at Warn, so debug and info records from the Rust core (key loads and creations, metastore calls) could not be observed from Python, and the docs described a set_log_hook_sync(..., min_level=...) that asherah-py does not provide. set_log_hook(callback, min_level=None) now accepts "error", "warn" (or "warning"), "info", "debug" or "trace", case-insensitively; omitting min_level or passing None keeps the Warn default. Any other string raises ValueError and a non-string raises TypeError, in both cases before the installed hook is touched. The level is applied to the async dispatcher, which drives log::max_level, and to the inner sink. The callback argument stays required, so set_log_hook() and set_log_hook(min_level="debug") raise TypeError instead of removing an installed hook. The type stub, README, getting-started and troubleshooting docs now describe the real API, and getting-started no longer mentions synchronous hook variants. The testing and AWS production setup examples that expected debug events (key loads, IK creation) from a default hook now install it at min_level="debug". Co-Authored-By: Claude <noreply@anthropic.com>
aka-bo
force-pushed
the
python-log-hook-min-level
branch
from
October 27, 2026 23:54
a626183 to
ed9028d
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
set_log_hookinstalled its sink at warn with no way to change it, so debug and info records from the Rust core (key loads and creations, metastore calls, per-region KMS failure detail) could not be observed from Python. The Python docs also described aset_log_hook_sync(..., min_level=...), whichasherah-pydoes not provide.Change
set_log_hook(callback, min_level=None)accepts"error","warn"(or"warning"),"info","debug"and"trace", case-insensitively. The default is warn.ValueErrorand a non-string raisesTypeError, in both cases before the installed hook is touched.log::max_level, and the inner sink.min_level="debug", and getting-started no longer mentions synchronous hook variants.Behavior changes
None for existing callers.
callbackremains required, as onmain; passingNonestill clears the hook; the default level is still warn.Scope
Python binding only. Stacked on the KMS error-message PR (#400).
Out of scope: a
min_leveloption for the Node and Java log hooks, which are also fixed at warn.Tests
In
asherah-py/tests/test_hooks.py:test_log_hook_min_level_debug_delivers_debug_records: the default hook receives only warn and error records during an encrypt; withmin_level="debug"debug records arrive and trace records do not.test_log_hook_invalid_min_level_raises_value_error: unknown names (empty,"verbose","critical") raiseValueErrorlisting the accepted values, a non-string raisesTypeError, and"WARNING"is accepted.test_log_hook_callback_is_required_and_rejected_calls_keep_the_hook:set_log_hook()raisesTypeError, and calls rejected for a missing callback or a bad level leave the installed debug hook receiving events.A Rust unit test covers the level-name parsing, including case,
warningand rejected names such asoff.🤖 Generated with Claude Code