Introduce UserOutput foundation (towards #60) - #140
Conversation
Issue useocl#60 proposes separating output meant for the USE user from developer logging, replacing the tangle of the static Log, USEWriter, raw System.out/err and ad-hoc PrintWriter arguments. This adds the foundation that future PRs can adopt incrementally, without changing any existing behavior: - OutputLevel: NORMAL, INFO, WARN, ERROR, TRACE - UserOutput: an interface whose single method print(level, message) drives the derived println and per-level convenience methods, plus factories for the default / silent / collecting outputs - StreamUserOutput: writes to print streams (warnings and errors to the error stream, everything else to the normal stream) - CollectingUserOutput: collects output in memory, per level, for tests and for capturing output - NullUserOutput: discards all output Purely additive (new classes only); nothing is migrated yet. Adds UserOutputTest covering stream routing, per-level separation, the convenience methods and the factories. https://claude.ai/code/session_01A85dAvTAvi2oWkGZH6REEq
Add @author Cansin Yildiz and @author Claude to the files added in this branch, and update the copyright year to 1999-2026. Co-authored-by: Claude <noreply@anthropic.com> https://claude.ai/code/session_01A85dAvTAvi2oWkGZH6REEq
f31f695 to
587430e
Compare
|
@cansin after 19 of July if your PRs hadn't been reviewed, just ping me here and I may see what I can do |
Ack. I will ping after the 19th. |
|
First of all: thanks for contributing to USE! I have one recommendation: move the new classes to a new package like |
Update: I've been having a bad cold since then, so I hadn't start checking on these properly. I will order the PRs and review one by one asap. |
Summary
A first, additive increment towards #60 (unify user and developer output).
#60 proposes separating output meant for the USE user from developer
logging, replacing the tangle of the static
Log,USEWriter, rawSystem.out/System.errand ad-hocPrintWriterarguments. That's a largemigration; this PR lands just the foundation so it can be adopted
incrementally.
This PR does not close #60 — it introduces the abstraction the issue
proposes, with no migration and no behavior change.
What's added (
org.tzi.use.util, all new)OutputLevel—NORMAL,INFO,WARN,ERROR,TRACE.UserOutput— interface with a singleprint(OutputLevel, String)that drivesthe derived
printlnand per-level convenience methods(
printlnNormal/printlnInfo/printlnWarn/printlnError/printlnTrace),plus factories for the default / silent / collecting outputs.
StreamUserOutput— writes to print streams (WARN/ERROR→ error stream,the rest → normal stream).
CollectingUserOutput— collects output in memory, per level (tests/capture).NullUserOutput— discards output.Testing
UserOutputTestcovers stream routing, per-level separation, the conveniencemethods,
printlnline separators, the silent output, and the factories. Thefull
use-coresuite (including the ArchUnit cyclic-dependency checks) passes.Suggested next steps (separate PRs)
Adopt
UserOutputwhere aPrintWriteris currently threaded through (e.g.USECompiler), then migrateLog's user-facing calls, keeping developerlogging on a logging framework.