Problem
base-bash-libs currently uses one logger-level map for terminal visibility,
while BASE_CLI_PRIMARY_LOG independently persists the DEBUG stream. That
supports quiet terminals plus complete diagnostics, but it does not provide a
separate component/category gate. A consuming application therefore cannot
enable its own DEBUG output while explicitly declining reusable-library DEBUG
records, nor can it cheaply test whether an expensive library diagnostic would
reach any sink.
The existing -l <logger> support is exact-only and is not a hierarchical
category contract.
Goal
Add a backward-compatible category gate that is independent from terminal and
persistent sink thresholds.
Scope
- Add
set_log_category_level -l <category> <level>.
- Resolve dotted categories in this order:
- exact category;
- nearest explicitly configured parent;
- the category
default.
- Keep the default category gate permissive through
VERBOSE during the
compatibility window so existing unscoped callers do not lose records.
- Add
log_is_enabled [-l <category>] <level>.
- Require a record to pass its category gate before either the terminal or
BASE_CLI_PRIMARY_LOG sink can consume it.
- Keep
set_log_level as the existing terminal-verbosity API.
- Let unconfigured named terminal loggers inherit the default terminal level,
while preserving explicit set_log_level -l <logger> <level> overrides.
- Apply the same category and sink decisions to file logging helpers.
- Document the public API and category-versus-sink model.
Acceptance criteria
- Existing unscoped
log_* and set_log_level behavior remains compatible.
- Default INFO terminal output plus
BASE_CLI_PRIMARY_LOG still persists
unscoped DEBUG records without printing them.
- Exact category configuration overrides a parent; a parent overrides
default; sibling categories remain independent.
- A category configured at INFO drops its DEBUG records from both stderr and
BASE_CLI_PRIMARY_LOG.
- A category configured at DEBUG with an INFO terminal and active primary sink
persists DEBUG without printing it.
log_is_enabled returns success only when the category accepts the level and
at least one configured sink would consume it.
log_is_enabled and set_log_category_level reject invalid levels and
malformed -l usage without mutating existing state.
- File logging helpers obey the same category gate.
- Focused BATS tests and the complete repository validation pass.
Non-goals
- Migrating the repository's own log calls to component categories.
- Deprecating or removing
VERBOSE.
- Changing rendered log-record formatting.
- Changing Base or Python logging behavior.
- Changing
VERSION or publishing a release.
Validation
- Focused coverage in
lib/bash/std/tests/lib_std.bats.
./tests/validate.sh
git diff --check
Related work
Problem
base-bash-libscurrently uses one logger-level map for terminal visibility,while
BASE_CLI_PRIMARY_LOGindependently persists the DEBUG stream. Thatsupports quiet terminals plus complete diagnostics, but it does not provide a
separate component/category gate. A consuming application therefore cannot
enable its own DEBUG output while explicitly declining reusable-library DEBUG
records, nor can it cheaply test whether an expensive library diagnostic would
reach any sink.
The existing
-l <logger>support is exact-only and is not a hierarchicalcategory contract.
Goal
Add a backward-compatible category gate that is independent from terminal and
persistent sink thresholds.
Scope
set_log_category_level -l <category> <level>.default.VERBOSEduring thecompatibility window so existing unscoped callers do not lose records.
log_is_enabled [-l <category>] <level>.BASE_CLI_PRIMARY_LOGsink can consume it.set_log_levelas the existing terminal-verbosity API.while preserving explicit
set_log_level -l <logger> <level>overrides.Acceptance criteria
log_*andset_log_levelbehavior remains compatible.BASE_CLI_PRIMARY_LOGstill persistsunscoped DEBUG records without printing them.
default; sibling categories remain independent.BASE_CLI_PRIMARY_LOG.persists DEBUG without printing it.
log_is_enabledreturns success only when the category accepts the level andat least one configured sink would consume it.
log_is_enabledandset_log_category_levelreject invalid levels andmalformed
-lusage without mutating existing state.Non-goals
VERBOSE.VERSIONor publishing a release.Validation
lib/bash/std/tests/lib_std.bats../tests/validate.shgit diff --checkRelated work
category gate must preserve.