Skip to content

Feat/log lazy and exceptions#106

Open
Brandhoej wants to merge 5 commits intoEcdar:mainfrom
Brandhoej:feat/log-lazy-and-exceptions
Open

Feat/log lazy and exceptions#106
Brandhoej wants to merge 5 commits intoEcdar:mainfrom
Brandhoej:feat/log-lazy-and-exceptions

Conversation

@Brandhoej
Copy link

@Brandhoej Brandhoej commented Mar 30, 2023

Allows for lazy evaluation of the object to log. To enable this a Supplier is used on each Urgency. Also some System.err.println was used and one print of the Exception stacktrace. Because of this Log now supports the printing of the Exception stacktrace with the LogPrintStream. For now the default method of printing exceptions uses the Urgency.Error but allows an overloaded method to have a custom Urgency.

@Brandhoej Brandhoej marked this pull request as ready for review April 7, 2023 07:11
@Brandhoej Brandhoej requested a review from magoorden April 7, 2023 07:11
Copy link
Contributor

@magoorden magoorden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not many comments on this one 😃.


@Override
public void println(Object x) {
switch (urgency) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am missing the default case for this switch statement.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. I guess an exception should be thrown like colorize. However, I think it can be dangerous to allow logging to throw exceptions so maybe logging exceptions should just use "Error" as default and colorize should not use any color?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still throw an exception, as reaching the default case is clearly a developer error, as the developer tries to do something with the Log class that it does not support. An end-user should not reach this point in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants