-
-
Notifications
You must be signed in to change notification settings - Fork 161
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
Only log halted pipes by default #1062
Conversation
spec/lucky/action_callbacks_spec.cr
Outdated
@@ -207,7 +207,7 @@ private def with_log | |||
log_formatter: RawLogFormatter | |||
) | |||
|
|||
Lucky.temp_config(logger: logger) do | |||
Lucky.temp_config(logger: logger, action_pipe_log_level: Logger::Severity::INFO) do |
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.
Actually, should we just call these before/after
macros callbacks? We kind of have callbacks and pipes in the code and guides so I think we should choose one.
I partly named them pipes because they work a bit more similarly to pipes in Elixir where you have to return an explicit response/continue. And also because "callbacks" is a bad word to some people. But maybe we should just call them callbacks since that may make more sense. Thoughts? @edwardloveall @jwoertink
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.
I think pipes is fine, but I don't think I feel too strongly either way. There's also an ick factor about callbacks for me, but not so strong that I'd steer away from the word itself if it's the best word to discribe.
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.
I like pipes because it sounds cool. Maybe that's because of callbacks having a bad taste, but we use the term "pipe" in our apps. I would like to see it a bit more standardized, and consistent though.
Like we have:
module RequireSitePipe
macro included
before require_site
end
private def require_site
if current_site?
continue
else
raise Lucky::RouteNotFoundError.new(context)
end
end
private def current_site : SiteHelpers::Site
current_site?.not_nil!
end
end
but just by looking at the name of the module, it doesn't immediately tell you why we added "Pipe" to it. We could have just called it RequireSite
.
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.
As mentioned in our gitter room I'll stick with pipes. I was just worried it was confusing. I'll make some changes to the code to be pipe instead of callback!
src/lucky.cr
Outdated
@@ -22,6 +22,7 @@ require "./lucky/paginator/*" | |||
module Lucky | |||
Habitat.create do | |||
setting logger : Dexter::Logger | |||
setting action_pipe_log_level : ::Logger::Severity? = nil, example: "Logger::Severity::INFO" |
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.
What does example
mean here? I think I could guess but I've never seen it. 😄
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.
example
is what gets displayed in the error message when it's not set. But since this is nilable, does it throw an error?
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.
Yeah it shows up if you forget to set it, but Jeremy is right that you'll never see it :P
I think I will leave it though since in the future I want to add a task to Habitat that will show the options available, examples, and also where the configuration is being set. It'll be pretty sick I think
spec/lucky/action_callbacks_spec.cr
Outdated
@@ -207,7 +207,7 @@ private def with_log | |||
log_formatter: RawLogFormatter | |||
) | |||
|
|||
Lucky.temp_config(logger: logger) do | |||
Lucky.temp_config(logger: logger, action_pipe_log_level: Logger::Severity::INFO) do |
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.
I think pipes is fine, but I don't think I feel too strongly either way. There's also an ick factor about callbacks for me, but not so strong that I'd steer away from the word itself if it's the best word to discribe.
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.
👍
spec/lucky/action_callbacks_spec.cr
Outdated
@@ -207,7 +207,7 @@ private def with_log | |||
log_formatter: RawLogFormatter | |||
) | |||
|
|||
Lucky.temp_config(logger: logger) do | |||
Lucky.temp_config(logger: logger, action_pipe_log_level: Logger::Severity::INFO) do |
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.
I like pipes because it sounds cool. Maybe that's because of callbacks having a bad taste, but we use the term "pipe" in our apps. I would like to see it a bit more standardized, and consistent though.
Like we have:
module RequireSitePipe
macro included
before require_site
end
private def require_site
if current_site?
continue
else
raise Lucky::RouteNotFoundError.new(context)
end
end
private def current_site : SiteHelpers::Site
current_site?.not_nil!
end
end
but just by looking at the name of the module, it doesn't immediately tell you why we added "Pipe" to it. We could have just called it RequireSite
.
src/lucky.cr
Outdated
@@ -22,6 +22,7 @@ require "./lucky/paginator/*" | |||
module Lucky | |||
Habitat.create do | |||
setting logger : Dexter::Logger | |||
setting action_pipe_log_level : ::Logger::Severity? = nil, example: "Logger::Severity::INFO" |
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.
example
is what gets displayed in the error message when it's not set. But since this is nilable, does it throw an error?
src/lucky/action_callbacks.cr
Outdated
@@ -127,10 +127,10 @@ module Lucky::ActionCallbacks | |||
# end | |||
|
|||
if callback_result.is_a?(Lucky::Response) | |||
Lucky::ActionCallbacks.log_stopped_callback(context,"{{ callback_method.id }}") | |||
Lucky::ActionCallbacks.log_stopped_callback("{{ callback_method.id }}") |
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.
Yeah, I see what you mean. This should be Lucky::ActionPipes.log_stopped_pipe
, or we go full on callback everywhere. I do like "pipe", but maybe we don't fight it since typing callback
just seems to be what you want to do first?
But allow customizing it so that you can see all pipes being logged Closes #1054
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.
Thanks for the reviews
spec/lucky/action_callbacks_spec.cr
Outdated
@@ -207,7 +207,7 @@ private def with_log | |||
log_formatter: RawLogFormatter | |||
) | |||
|
|||
Lucky.temp_config(logger: logger) do | |||
Lucky.temp_config(logger: logger, action_pipe_log_level: Logger::Severity::INFO) do |
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.
As mentioned in our gitter room I'll stick with pipes. I was just worried it was confusing. I'll make some changes to the code to be pipe instead of callback!
src/lucky.cr
Outdated
@@ -22,6 +22,7 @@ require "./lucky/paginator/*" | |||
module Lucky | |||
Habitat.create do | |||
setting logger : Dexter::Logger | |||
setting action_pipe_log_level : ::Logger::Severity? = nil, example: "Logger::Severity::INFO" |
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.
Yeah it shows up if you forget to set it, but Jeremy is right that you'll never see it :P
I think I will leave it though since in the future I want to add a task to Habitat that will show the options available, examples, and also where the configuration is being set. It'll be pretty sick I think
b3a7e6b
to
bf1c82d
Compare
bf1c82d
to
1817128
Compare
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.
☕️
It is passing but not reporting back to GitHub so I'll merge https://travis-ci.org/github/luckyframework/lucky |
We had that problem on a different project also where circle wasn't reporting to GH. Maybe it's the same problem? hotline-webring/hotline-webring#273 |
But allow customizing it so that you can see all pipes being logged
Closes #1054