Beautify logging code and output #17

Merged
Jan Lindemann merged 5 commits from jan/feature/20260617-beautify-logging-code-and-output into master 2026-06-17 17:19:39 +02:00 AGit

The biggest change this pull request introduces is integrating jw-python's log module, which makes for much nicer logging. The PR also adds some smaller fixes and enhancements in logging-related code.

lib.Types.LoadTypes: Beautify logging code

Shorten redundant occurences of .format(mod_name, member_name).

lib.Types.LoadTypes: Loosen type_filter type

In LoadTypes' constructor, allow the type_filter parameter to be of type Sequence[type[Any]] instead of list[type[T]]. a) Sequence is more generic than list, and b) with T instead of Any, trying to instantiate with an abstract class has mypy complain:

E: Only concrete class can be given where "type[MyClass]" is expected  [type-abstract]

  - type_filter: list[type[T]] = [],
  + type_filter: Sequence[type[Any]] | None = None,

Note that this makes mypy complain that it needs an annotation at the places where LoadTypes is used.

log: Use jw-python's log implementation

Use the (mostly) call-compatible log implementation from jw-python. This buys us much nicer logs with color and source-code positon annotations.

lib.Result: Fill "cmd" ctor parameter

Commands executed by ExecContext and its derived classes don't populate the "cmd" parameter of "Result"'s constructor. Fixing that makes for nicer error messages.

lib.App.run(): Use pretty_cmd() for logging command line

The command line jw-pkg.py is run with is logged with level "debug", and reconstructed with ' '.join(sys.argv). Use pretty_cmd() instead, this adds quotes around spaces.

The biggest change this pull request introduces is integrating jw-python's log module, which makes for much nicer logging. The PR also adds some smaller fixes and enhancements in logging-related code. #### lib.Types.LoadTypes: Beautify logging code Shorten redundant occurences of .format(mod_name, member_name). #### lib.Types.LoadTypes: Loosen type_filter type In LoadTypes' constructor, allow the type_filter parameter to be of type Sequence[type[Any]] instead of list[type[T]]. a) Sequence is more generic than list, and b) with T instead of Any, trying to instantiate with an abstract class has mypy complain: ``` E: Only concrete class can be given where "type[MyClass]" is expected [type-abstract] - type_filter: list[type[T]] = [], + type_filter: Sequence[type[Any]] | None = None, ``` Note that this makes mypy complain that it needs an annotation at the places where LoadTypes is used. #### log: Use jw-python's log implementation Use the (mostly) call-compatible log implementation from jw-python. This buys us much nicer logs with color and source-code positon annotations. #### lib.Result: Fill "cmd" ctor parameter Commands executed by ExecContext and its derived classes don't populate the "cmd" parameter of "Result"'s constructor. Fixing that makes for nicer error messages. #### lib.App.run(): Use pretty_cmd() for logging command line The command line jw-pkg.py is run with is logged with level "debug", and reconstructed with ' '.join(sys.argv). Use pretty_cmd() instead, this adds quotes around spaces.

Shorten redundant occurences of .format(mod_name, member_name).

Signed-off-by: Jan Lindemann <jan@janware.com>

In LoadTypes' constructor, allow the type_filter parameter to be of type Sequence[type[Any]] instead of list[type[T]]. a) Sequence is more generic than list, and b) with T instead of Any, trying to instantiate with an abstract class has mypy complain:

# E: Only concrete class can be given where "type[MyClass]" is expected [type-abstract]

- type_filter: list[type[T]] = [], + type_filter: Sequence[type[Any]] | None = None,

Not that this makes mypy complain that it needs an annotation at the places where LoadTypes is used.

Signed-off-by: Jan Lindemann <jan@janware.com>

Use the (mostly) call-compatible log implementation from jw-python. This buys us much nicer logs with color and source-code positon annotations.

Signed-off-by: Jan Lindemann <jan@janware.com>

Commands executed by ExecContext and its derived classes don't populate the "cmd" parameter of "Result"'s constructor. Fixing that makes for nicer error messages.

Signed-off-by: Jan Lindemann <jan@janware.com>
lib.App.run(): Use pretty_cmd() for logging command line
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 3m26s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 3m25s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 3m10s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 3m5s
CI / Packaging test (push) Successful in 0s
7088e33cfe

The command line jw-pkg.py is run with is logged with level "debug", and reconstructed with ' '.join(sys.argv). Use pretty_cmd() instead, this adds quotes around spaces.

Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-06-17 17:14:29 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
janware/jw-pkg!17
No description provided.