onelogin / onelogin-go-sdk

golang sdk for onelogin apis
MIT License
10 stars 24 forks source link

Support for request/response logging? #37

Closed dlethin closed 1 year ago

dlethin commented 3 years ago

I had originally made a request here in the terraform-provider-onlogin repo to add support for onelogin API request/response debug logging.

Other providers include support for this and it helps tremendously troubleshooting issue and communicating with provider developers sharing log output. Terraform writes about implementing provider logging here

I've attached an example below of logging coming from the terraform-gsuite-provider visible when we set the TF_LOG env variable to debug:

Obviously this repo is not specific to terraform but this the repo the terraform-onelogin-provider uses as the client for the API, so changes might be made here to provide a way for terraform to capture where it wants to send the logs to which in the case of terraform I beleive would just be to stderr.

Thanks.

Doug

Example API request/response logging coming from the terraform-gsuite-provider:

2021-06-12T10:48:16.543-0400 [WARN]  ValidateProviderConfig from "provider[\"registry.terraform.io/onelogin/onelogin\"]" changed the config value, but that value is unused
2021-06-12T10:48:16.543-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: 2021/06/12 10:48:16 [DEBUG] Waiting for state to become: [success]
2021-06-12T10:48:16.544-0400 [DEBUG] ReferenceTransformer: "data.onelogin_user.self" references: []
2021-06-12T10:48:16.544-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: 2021/06/12 10:48:16 [DEBUG] Google API Request Details:
2021-06-12T10:48:16.544-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: ---[ REQUEST ]---------------------------------------
2021-06-12T10:48:16.544-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: GET /admin/directory/v1/groups/REDACTED?alt=json&prettyPrint=false HTTP/1.1
2021-06-12T10:48:16.544-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: Host: admin.googleapis.com
2021-06-12T10:48:16.544-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: User-Agent: google-api-go-client/0.5 (darwin amd64) Terraform/0.15.3
2021-06-12T10:48:16.544-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: X-Goog-Api-Client: gl-go/1.16.3 gdcl/REDACTED
2021-06-12T10:48:16.544-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: Accept-Encoding: gzip
2021-06-12T10:48:16.544-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62:
2021-06-12T10:48:16.544-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62:
2021-06-12T10:48:16.544-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: -----------------------------------------------------
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: 2021/06/12 10:48:16 [DEBUG] Google API Response Details:
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: ---[ RESPONSE ]--------------------------------------
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: HTTP/2.0 200 OK
...
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: Cache-Control: private
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: Content-Type: application/json; charset=UTF-8
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: Date: Sat, 12 Jun 2021 14:48:17 GMT
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: Etag: "REDACTED"
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: Server: ESF
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: Vary: Origin
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: Vary: X-Origin
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: Vary: Referer
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: X-Content-Type-Options: nosniff
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: X-Frame-Options: SAMEORIGIN
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: X-Xss-Protection: 0
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62:
2021-06-12T10:48:16.957-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: {
2021-06-12T10:48:16.958-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62:  "kind": "admin#directory#group",
2021-06-12T10:48:16.958-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62:  "id": "REDACTED",
2021-06-12T10:48:16.958-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62:  "etag": "REDACTED",
2021-06-12T10:48:16.958-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62:  "email": "REDACTED",
2021-06-12T10:48:16.958-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62:  "name": "REDACTED",
2021-06-12T10:48:16.958-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62:  "directMembersCount": "2",
2021-06-12T10:48:16.958-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62:  "description": "REDACTED",
2021-06-12T10:48:16.958-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62:  "adminCreated": true,
2021-06-12T10:48:16.958-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62:  "nonEditableAliases": [
2021-06-12T10:48:16.958-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62:   "REDACTED",
2021-06-12T10:48:16.958-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62:   "REDACTED"
2021-06-12T10:48:16.958-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62:  ]
2021-06-12T10:48:16.958-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: }
2021-06-12T10:48:16.958-0400 [DEBUG] provider.terraform-provider-gsuite_v0.1.62: -----------------------------------------------------
Jmfwolf commented 1 year ago

This issue should be resolved now that the terraform-provider-onelogin is independent of this SDK