Skip to content

Commit

Permalink
Add logging based on env var (#821)
Browse files Browse the repository at this point in the history
* Add logging based on env var

* Update readme with logging

* Add issue template

* Clarify log location

* Update issue template

Update .github/ISSUE_TEMPLATE.md

Co-authored-by: Graham F. Scott <[email protected]>

* Use env var as path

* Update readme with log path

* Update README.md

Co-authored-by: Andy Waite <[email protected]>

* Move log subscriber into logging setup

* Update Changelog

Co-authored-by: Graham F. Scott <[email protected]>
Co-authored-by: Andy Waite <[email protected]>
  • Loading branch information
3 people authored Jan 13, 2021
1 parent 55dc828 commit ade2f3d
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 27 deletions.
36 changes: 36 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Issue summary

Write a short description of the issue here ↓



## Expected behavior

What do you think should happen?



## Actual behavior

What actually happens?

Tip: include an error message (in a `<details></details>` tag) if your issue is related to an error



## Steps to reproduce the problem

1.
1.
1.

## Logs
If applicable, enable the logs as described in the README, and paste the relevant portion here.



## Specifications

- `shopify_api` version:
- `activeresource` version:
- Shopify API version used (example: `2020-07`):
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

* [#802](https://github.com/Shopify/shopify_api/pull/802) Made `inventory_quantity` a read-only field in Variant

* [#821](https://github.com/Shopify/shopify_api/pull/821) Add logging based on environment variable, move log subscriber out of `detailed_log_subscriber`.
The `ActiveResource::DetailedLogSubscriber` no longer automatically attaches when the class is loaded. If you were previously relying on that behaviour, you'll now need to call `ActiveResource::DetailedLogSubscriber.attach_to(:active_resource_detailed)`. (If using the new `SHOPIFY_LOG_PATH` environment setting then this is handled for you).

## Version 9.2.0

* Removes the `shopify` binary which will be used by the Shopify CLI
Expand Down
60 changes: 35 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,36 @@ The REST API is implemented as JSON over HTTP using all four verbs (GET/POST/PUT

- [Shopify API](#shopify-api)
- [Usage](#usage)
* [Requirements](#requirements)
+ [Ruby version](#ruby-version)
* [Installation](#installation)
* [Getting Started](#getting-started)
+ [1) Create an app](#1-create-an-app)
+ [2A) Private Apps](#2a-private-apps)
+ [2B) Public and Custom Apps](#2b-public-and-custom-apps)
+ [3) Requesting access from a shop](#3-requesting-access-from-a-shop)
+ [4) Trading your `code` for an access token.](#4-trading-your--code--for-an-access-token)
+ [5) Activating the session](#5-activating-the-session)
+ [6A) Making requests to the GraphQL API](#6a-making-requests-to-the-graphql-api)
+ [6B) Making requests to the REST API](#6b-making-requests-to-the-rest-api)
* [Console](#console)
* [Thread safety](#thread-safety)
* [Bulk Operations](#bulk-operations)
+ [Example](#example)
- [Requirements](#requirements)
- [Ruby version](#ruby-version)
- [Installation](#installation)
- [Getting Started](#getting-started)
- [1) Create an app](#1-create-an-app)
- [2A) Private Apps](#2a-private-apps)
- [2B) Public and Custom Apps](#2b-public-and-custom-apps)
- [3) Requesting access from a shop](#3-requesting-access-from-a-shop)
- [4) Trading your `code` for an access token.](#4-trading-your-code-for-an-access-token)
- [5) Activating the session](#5-activating-the-session)
- [6A) Making requests to the GraphQL API](#6a-making-requests-to-the-graphql-api)
- [Note: the GraphQL client has improved and changed in version 9.0. See the client documentation for full usage details and a [migration guide](docs/graphql.md#migration-guide).](#note-the-graphql-client-has-improved-and-changed-in-version-90-see-the-client-documentation-for-full-usage-details-and-a-migration-guide)
- [6B) Making requests to the REST API](#6b-making-requests-to-the-rest-api)
- [Console](#console)
- [Thread safety](#thread-safety)
- [Bulk Operations](#bulk-operations)
- [Example](#example)
- [1) Start the bulk operation](#1-start-the-bulk-operation)
- [2) Poll the status of the bulk operation](#2-poll-the-status-of-the-bulk-operation)
- [3) Retrieve your data](#3-retrieve-your-data)
* [Pagination](#pagination)
- [Step 2) Poll the status of the bulk operation](#step-2-poll-the-status-of-the-bulk-operation)
- [Step 3) Retrieve your data](#step-3-retrieve-your-data)
- [Pagination](#pagination)
- [Breaking Change Notices](#breaking-change-notices)
* [Breaking change notice for version 8.0.0](#breaking-change-notice-for-version-800)
* [Breaking change notice for version 7.0.0](#breaking-change-notice-for-version-700)
+ [Changes to ShopifyAPI::Session](#changes-to-shopifyapi--session)
+ [Changes to how to define resources](#changes-to-how-to-define-resources)
+ [URL construction](#url-construction)
+ [URLs that have not changed](#urls-that-have-not-changed)
- [Breaking change notice for version 8.0.0](#breaking-change-notice-for-version-800)
- [Breaking change notice for version 7.0.0](#breaking-change-notice-for-version-700)
- [Changes to ShopifyAPI::Session](#changes-to-shopifyapisession)
- [Changes to how to define resources](#changes-to-how-to-define-resources)
- [URL construction](#url-construction)
- [URLs that have not changed](#urls-that-have-not-changed)
- [Using Development Version](#using-development-version)
- [Logging](#logging)
- [Additional Resources](#additional-resources)
- [Copyright](#copyright)

Expand Down Expand Up @@ -626,6 +628,14 @@ or you can even use our automated rake task for docker:
bundle exec rake docker
```

# Logging

Enable ActiveResource's logger with

`export SHOPIFY_LOG_PATH={your_log_path}`

This will log to a file at the given path, relative to the current project directory.

# Additional Resources

* [GraphQL API Reference](https://shopify.dev/docs/admin-api/graphql/reference)
Expand Down
2 changes: 0 additions & 2 deletions lib/active_resource/detailed_log_subscriber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,3 @@ def warn_on_deprecated_header_or_version_eol_header(event)
end
end
end

ActiveResource::DetailedLogSubscriber.attach_to(:active_resource_detailed)
5 changes: 5 additions & 0 deletions lib/shopify_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ module ShopifyAPI
else
require 'active_resource/connection_ext'
end

if ENV["SHOPIFY_LOG_PATH"]
ActiveResource::Base.logger = Logger.new(ENV["SHOPIFY_LOG_PATH"])
ActiveResource::DetailedLogSubscriber.attach_to(:active_resource_detailed)
end

0 comments on commit ade2f3d

Please sign in to comment.