-
Notifications
You must be signed in to change notification settings - Fork 479
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
Add Logger to library #1069
Add Logger to library #1069
Conversation
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.
Glad to see this functionality in the API! 🎉 🍻 Hopefully these changes don't take too long and make sense. If not, let me know and I'll be happy to help ya!
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.
Some question around consistency of deprecated log message/configuration as I already mentioned on your other PR
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.
If I could approve I would. Thanks Nelson for the additions!
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.
Awesome work guys! This looks pretty good!
Description
This PR moves the logger we had in shopify_app into the api library. This ensures that our logs are consistent across both repos.
How does it work?
Almost everything is the same but instead of storing the log level in
ShopifyApp::Configuration
, it's stored inShopifyAPI::Context
. So now if developers what to change the log level they would need to change it in theirShopify::Context.setup(...)
call. Which lives in the same file as the shopify_app configurations. (config/intializers/shopify_app.rb
)I switched the
Logger
module to a class. This letsshopify_app
create its own logger class and inherit its functionality, and override areas that deviate. For example there is no way to compare the version number in theshopify_app
if the logger lives solely in the api. Also we should have a slightly differentcontext
method. Where the api would have "ShopifyAPI" as a prefix and theshopify_app
would have "ShopifyApp". This will help developers know where exactly these logs are coming from.I also made some error classes,
FeatureDeprecatedError
andLogLevelNotFound
for the errors that we raise in methods found inLogger
. Hopefully this gives some good hints on what is going on when the logger raises an error.How has this been tested?
I also made a test file in
test/logger_test.rb
which does some unit tests on most of the logic found in theLogger
class.Checklist: