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
Allow custom loggers #768
Allow custom loggers #768
Conversation
* Generate empty `lib/<project-name>.rb` file * Generate new projects with empty module in `lib/<project_name>.rb` Example: $ hanami new cool_project $ cd cool_project $ cat lib/cool_project.rb module CoolProject end
…unning it in a separated process
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 this idea. But I have some little issues and what to discuss about it.
@hanami/core WDYT?
lib/hanami/components/components.rb
Outdated
@@ -28,7 +28,13 @@ module Components # rubocop:disable Metrics/ModuleLength | |||
end | |||
|
|||
resolve do |configuration| | |||
Hanami::Logger.new(Hanami.environment.project_name, *configuration.logger) unless configuration.logger.nil? | |||
if configuration.logger.is_a?(Array) | |||
if configuration.logger.length == 1 && configuration.logger[0].is_a?(::Logger) |
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.
maybe just configuration.logger.fist.is_a?(::Logger)
?
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.
and are you sure that this code will work with other loggers (for example logging)?
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.
Yes, I don't see any reason it wouldn't unless the internal usage of the logger in Hanami deviates from the standard ::Logger
interface. Otherwise, this should work great.
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.
maybe just configuration.logger.fist.is_a?(::Logger)?
Done
Yes, please let me know the consensus. Hanami is so refreshing to work with in comparison to alternatives, so it's no surprise we have multiple customers at @timberio that are using it. But they can't unless we patch how the logger is set. Moreover, there are quite a few other Logging alternatives (as you pointed out), and restricting everyone to |
Also, do you mind expanding on the issues that concern you? Maybe I can help or write code that addresses them? |
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.
Albeit not being a fan of double ifs, I have no suggestion to refactor that, so.... LGTM
Thanks! Are we good to ship it? |
@davydovanton any other non-addressed points? |
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.
@binarylogic Hi and thanks for this PR. LGTM 👍
Side note: I don't like that if, but it seems the easiest way to implement this feature so .
@binarylogic Would you be so kind to add the documentation part of this on hanami/hanami.github.io
repository, so it will appear here: http://hanamirb.org/guides/projects/logging/
Tnx! 👍
@davydovanton Please review again an let us to know WDYT. Thanks. |
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.
great work 👏
@jodosha absolutely, I'll try to get on it today or tomorrow |
As everyone is happy and merry, @binarylogic could you rebase it on hanami:develop and push it, so I can merge it? |
@mereghost by clicking on "Squash and merge" should solve the rebase problem, right? |
@jodosha It seems it's not an interactive squash, so I can't discard commits. >.< |
Hey guys, any update here? It appears the branch has no conflicts at the moment. |
Currently Hanami only takes an array of arguments that get passed to the
Hanami::Logger
class. This change allows the use of a custom Logger by passing a single object during configuration. For example:This change was prompted in order to install the Timber logger which handles capturing context and structure automatically.