-
-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging returns true
#65
Conversation
|
b0e0c88
to
a3b16b9
Compare
This looks somewhat reasonable to me. I think if we had to establish a behaviour, it should be that the log operation returns truthy if it does something and falsey otherwise. I believe Regarding the other cases, I'm okay for them to return true if something was logged or not. What do you think? |
I have two thought: 1st: I assume 2nd: Personally, I like to have a consistent return value. My code should not need to care if the log has been written or not. def do_something
# more code
Console.error("we did something") unless it_was_done
end Now, in tests and development, you'll probably have error logging on, but in production, you might raise the log lever to fatal. Suddenly your method would return a different value. I've went ahead with returning Anyways, If you have projects relying on truthy/falsey return values, let's do that, but also add some "jumps-in-your-eye" documentation :) |
test/console/filter.rb
Outdated
@@ -70,25 +74,28 @@ def before | |||
it "ignores messages below the level" do | |||
logger.level = Console::Logger::INFO | |||
|
|||
logger.call(MySubject, "Hello World", severity: :debug) | |||
retval = logger.call(MySubject, "Hello World", severity: :debug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
retval = logger.call(MySubject, "Hello World", severity: :debug) | |
result = logger.call(MySubject, "Hello World", severity: :debug) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
If we are planning to return the same thing everywhere, why not always return nil? In other words:
|
I'm totally fine with always returning The current proposal was only to be more compatible with Rubies Logger. |
Okay, please let me think about it. |
- regardless of used outputs - regardless of effective log level
a3b16b9
to
9b40a86
Compare
I've decided to go ahead with always returning Honestly, I could see different ways this could be implemented. Returning |
Thanks for your contribution, closing in favour of #68. |
See #64
Types of Changes
Console.info
) consistently returntrue
regardless of OutputContribution