Преглед на файлове

Add logging based on env var (#821)

* 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 <gfscott@users.noreply.github.com>

* Use env var as path

* Update readme with log path

* Update README.md

Co-authored-by: Andy Waite <andyw8@users.noreply.github.com>

* Move log subscriber into logging setup

* Update Changelog

Co-authored-by: Graham F. Scott <gfscott@users.noreply.github.com>
Co-authored-by: Andy Waite <andyw8@users.noreply.github.com>
Melanie Wang преди 3 години
родител
ревизия
ade2f3d36a
променени са 5 файла, в които са добавени 79 реда и са изтрити 27 реда
  1. 36 0
      .github/ISSUE_TEMPLATE.md
  2. 3 0
      CHANGELOG.md
  3. 35 25
      README.md
  4. 0 2
      lib/active_resource/detailed_log_subscriber.rb
  5. 5 0
      lib/shopify_api.rb

+ 36 - 0
.github/ISSUE_TEMPLATE.md

@@ -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 - 0
CHANGELOG.md

@@ -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

+ 35 - 25
README.md

@@ -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)
 
@@ -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)

+ 0 - 2
lib/active_resource/detailed_log_subscriber.rb

@@ -49,5 +49,3 @@ module ActiveResource
     end
   end
 end
-
-ActiveResource::DetailedLogSubscriber.attach_to(:active_resource_detailed)

+ 5 - 0
lib/shopify_api.rb

@@ -32,3 +32,8 @@ if ShopifyAPI::Base.respond_to?(:connection_class)
 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