Skip to content
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

Merged
merged 2 commits into from
Mar 24, 2020
Merged

Conversation

paulcsmith
Copy link
Member

But allow customizing it so that you can see all pipes being logged

Closes #1054

@@ -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
Copy link
Member Author

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

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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"
Copy link
Member

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. 😄

Copy link
Member

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?

Copy link
Member Author

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

@@ -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
Copy link
Member

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.

Copy link
Member

@jwoertink jwoertink left a comment

Choose a reason for hiding this comment

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

👍

@@ -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
Copy link
Member

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"
Copy link
Member

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?

@@ -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 }}")
Copy link
Member

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
Copy link
Member Author

@paulcsmith paulcsmith left a 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

@@ -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
Copy link
Member Author

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"
Copy link
Member Author

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

@paulcsmith paulcsmith force-pushed the pcs/1054-only-log-halt-by-default branch 4 times, most recently from b3a7e6b to bf1c82d Compare March 24, 2020 17:15
paulcsmith added a commit to luckyframework/lucky_cli that referenced this pull request Mar 24, 2020
@paulcsmith paulcsmith force-pushed the pcs/1054-only-log-halt-by-default branch from bf1c82d to 1817128 Compare March 24, 2020 19:51
Copy link
Contributor

@jkthorne jkthorne left a comment

Choose a reason for hiding this comment

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

☕️

@paulcsmith
Copy link
Member Author

It is passing but not reporting back to GitHub so I'll merge https://travis-ci.org/github/luckyframework/lucky

@paulcsmith paulcsmith merged commit 5d207b2 into master Mar 24, 2020
@paulcsmith paulcsmith deleted the pcs/1054-only-log-halt-by-default branch March 24, 2020 20:08
paulcsmith added a commit to luckyframework/lucky_cli that referenced this pull request Mar 24, 2020
@edwardloveall
Copy link
Member

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

paulcsmith added a commit to luckyframework/lucky_cli that referenced this pull request Mar 24, 2020
paulcsmith added a commit to luckyframework/lucky_cli that referenced this pull request Apr 7, 2020
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.

Add option to only log 'before/after' pipes if the pipe halts
4 participants