feat: redirecting System.out and System.err to logger infrastructure #5

Closed
opened 2024-08-20 22:30:07 +02:00 by JeremyStarTM · 1 comment
Owner

Feature description

It may be a good idea to redirect the System.out and System.err PrintStreams to Logger#info() and Logger#error() respectively, for applications and libraries using standard streams for logging. This would also allow for using the replaced PrintStream for specific purposes (example: GLFW error callbacks accept PrintStreams).

Feature implementation

Replacing System.out and System.err PrintStreams.

Feature alternatives

No response

### Feature description It may be a good idea to redirect the `System.out` and `System.err` `PrintStream`s to `Logger#info()` and `Logger#error()` respectively, for applications and libraries using standard streams for logging. This would also allow for using the replaced `PrintStream` for specific purposes (example: GLFW error callbacks accept `PrintStream`s). ### Feature implementation Replacing `System.out` and `System.err` `PrintStream`s. ### Feature alternatives _No response_
JeremyStarTM added the
FeatureRequest
New
label 2024-08-20 22:30:07 +02:00
Author
Owner

Maybe it's not the best idea to replace System.out and System.err, as internal engine logic depends on them. This would require code changes not only in the logging infrastructure but in all places where the standard streams are used. Implementing this FR would require creating a constant with a reference to the original PrintStreams.

However, even though the full FR will likely not get implemented, offering PrintStreams which redirect log messages to our own logger implementation sounds interesting. Just not doing that globally, for the entire JVM, is a good idea.

Maybe it's not the best idea to replace `System.out` and `System.err`, as internal engine logic [depends](https://git.staropensource.de/StarOpenSource/Engine/src/commit/5718f33d88cd57ef2924e882a2055fbff39d745d/base/src/main/java/de/staropensource/sosengine/base/classes/ShortcodeParserSkeleton.java) [on](https://git.staropensource.de/StarOpenSource/Engine/src/commit/5718f33d88cd57ef2924e882a2055fbff39d745d/base/src/main/java/de/staropensource/sosengine/base/logging/implementation/PlainLoggerImplementation.java#L63-L67) [them](https://git.staropensource.de/StarOpenSource/Engine/src/commit/5718f33d88cd57ef2924e882a2055fbff39d745d/base/src/main/java/de/staropensource/sosengine/base/logging/implementation/RawLoggerImplementation.java#L62-L66). This would require code changes not only in the logging infrastructure but in all places where the standard streams are used. Implementing this FR would require creating a constant with a reference to the original `PrintStream`s. However, even though the full FR will likely not get implemented, offering `PrintStream`s which redirect log messages to our own logger implementation sounds interesting. Just not doing that globally, for the entire JVM, is a good idea.
JeremyStarTM added this to the v1-release0 milestone 2024-08-21 00:14:15 +02:00
JeremyStarTM added
FeatureRequest
Accepted
and removed
FeatureRequest
New
labels 2024-08-21 13:34:56 +02:00
JeremyStarTM added
FeatureRequest
Implemented
and removed
FeatureRequest
Accepted
labels 2024-08-21 19:34:38 +02:00
Sign in to join this conversation.
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.

Reference: StarOpenSource/Engine#5
No description provided.