Skip to content
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

chore: complete migration to mlog and drop logrus #729

Merged
merged 1 commit into from
Feb 4, 2023

Conversation

enj
Copy link
Member

@enj enj commented Feb 1, 2023

Signed-off-by: Monis Khan [email protected]

Fixes #705

Example logs with --debug:

Wed, 01 Feb 2023 17:43:07 EST  auth/provider.go:191  No subscription provided, using selected subscription from Azure CLI  {"subscription-id": "ID_HERE"}
Wed, 01 Feb 2023 17:43:07 EST  cloud/azureclient.go:235  Resolving tenantID  {"subscriptionID": "ID_HERE"}
Wed, 01 Feb 2023 17:43:07 EST  serviceaccount/delete.go:115  --aad-application-name not specified, constructing name with service account namespace, name, and the hash of the issuer URL  {"warning": true}
Wed, 01 Feb 2023 17:43:07 EST  cloud/graph.go:96  Getting application  {"display name": "default-foo-T"}
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:466  curl -v -XGET  -H "User-Agent: azsdk-go-azidentity/v0.13.2 azsdk-go-azcore/v0.21.0 (go1.19.4; darwin)" 'https://login.microsoftonline.com/common/discovery/instance?api-version=1.1&authorization_endpoint=https%3A%2F%2Flogin.microsoftonline.com%2FID_HERE%2Foauth2%2Fv2.0%2Fauthorize'
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:495  HTTP Trace: DNS Lookup for login.microsoftonline.com resolved to [{20.190.151.9 } {20.190.151.6 } {20.190.151.134 } {20.190.151.70 } {20.190.151.68 } {20.190.151.133 } {20.190.151.8 } {20.190.151.67 }]
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:510  HTTP Trace: Dial to tcp:20.190.151.9:443 succeed
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:553  GET https://login.microsoftonline.com/common/discovery/instance?api-version=1.1&authorization_endpoint=https%3A%2F%2Flogin.microsoftonline.com%2FID_HERE%2Foauth2%2Fv2.0%2Fauthorize 200 OK in 157 milliseconds
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:570  HTTP Statistics: DNSLookup 2 ms Dial 21 ms TLSHandshake 51 ms ServerProcessing 82 ms Duration 157 ms
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:577  Response Headers:
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:580      Strict-Transport-Security: max-age=31536000; includeSubDomains
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:580      Set-Cookie: COOKIE
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:580      Client-Request-Id: 51f24826-4e88-47c7-b2a2-0efbcd19bdff
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:580      X-Ms-Request-Id: ae92df0e-ecfd-4a18-bd95-b3677306fc00
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:580      X-Content-Type-Options: nosniff
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:580      Access-Control-Allow-Origin: *
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:580      P3p: CP="DSP CUR OTPi IND OTRi ONL FIN"
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:580      X-Xss-Protection: 0
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:580      Content-Length: 980
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:580      Cache-Control: max-age=86400, private
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:580      Access-Control-Allow-Methods: GET, OPTIONS
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:580      X-Ms-Ests-Server: 2.1.14601.8 - WUS2 ProdSlices
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:580      Content-Type: application/json; charset=utf-8
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:580      Date: Wed, 01 Feb 2023 22:43:07 GMT
Wed, 01 Feb 2023 17:43:07 EST  transport/round_trippers.go:466  curl -v -XGET  -H "User-Agent: azsdk-go-azidentity/v0.13.2 azsdk-go-azcore/v0.21.0 (go1.19.4; darwin)" 'https://login.microsoftonline.com/ID_HERE/v2.0/.well-known/openid-configuration'
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:553  GET https://login.microsoftonline.com/ID_HERE/v2.0/.well-known/openid-configuration 200 OK in 51 milliseconds
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:570  HTTP Statistics: GetConnection 0 ms ServerProcessing 51 ms Duration 51 ms
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:577  Response Headers:
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Client-Request-Id: 14eb8e3e-b6b0-4790-98d6-308f1b18be92
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      X-Ms-Request-Id: 50171151-8120-40e1-833c-38f04531e400
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      X-Xss-Protection: 0
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Set-Cookie: COOKIE
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      X-Content-Type-Options: nosniff
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      P3p: CP="DSP CUR OTPi IND OTRi ONL FIN"
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Strict-Transport-Security: max-age=31536000; includeSubDomains
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      X-Ms-Ests-Server: 2.1.14601.8 - NCUS ProdSlices
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Date: Wed, 01 Feb 2023 22:43:07 GMT
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Content-Length: 1753
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Access-Control-Allow-Origin: *
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Access-Control-Allow-Methods: GET, OPTIONS
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Cache-Control: max-age=86400, private
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Content-Type: application/json; charset=utf-8
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:466  curl -v -XPOST  -H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" -H "Content-Length: 176" -H "User-Agent: azsdk-go-azidentity/v0.13.2 azsdk-go-azcore/v0.21.0 (go1.19.4; darwin)" 'https://login.microsoftonline.com/ID_HERE/oauth2/v2.0/token'
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:553  POST https://login.microsoftonline.com/ID_HERE/oauth2/v2.0/token 400 Bad Request in 212 milliseconds
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:570  HTTP Statistics: GetConnection 0 ms ServerProcessing 211 ms Duration 212 ms
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:577  Response Headers:
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      X-Content-Type-Options: nosniff
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      P3p: CP="DSP CUR OTPi IND OTRi ONL FIN"
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Set-Cookie: COOKIE
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Expires: -1
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Strict-Transport-Security: max-age=31536000; includeSubDomains
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      X-Ms-Request-Id: be8dbd12-e496-499c-a5f4-f4dccb23ea00
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Cache-Control: no-store, no-cache
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Content-Type: application/json; charset=utf-8
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      X-Xss-Protection: 0
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Date: Wed, 01 Feb 2023 22:43:07 GMT
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Content-Length: 752
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Pragma: no-cache
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      Client-Request-Id: 18a4f8ec-abf0-4010-82cb-950870a5aa18
Wed, 01 Feb 2023 17:43:08 EST  transport/round_trippers.go:580      X-Ms-Ests-Server: 2.1.14601.8 - WUS2 ProdSlices

@enj enj requested a review from aramase as a code owner February 1, 2023 16:56
@enj enj force-pushed the enj/i/mlog_migrate_logrus branch 3 times, most recently from 19bd5e4 to 974e7af Compare February 1, 2023 22:46
@enj enj enabled auto-merge (squash) February 2, 2023 00:55
@@ -49,7 +49,7 @@ func (c *AzureClient) CreateApplication(ctx context.Context, displayName string)
}
appPostOptions.Body.SetDisplayName(to.StringPtr(displayName))

log.Debugf("Creating application with display name=%s", displayName)
mlog.Debug("Creating application", "display name", displayName)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we move to structured logging, should the key be camel case? displayName instead of display name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am happy either way: which way do you prefer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's use the camel case keys

@@ -120,19 +120,19 @@ func (c *AzureClient) GetApplication(ctx context.Context, displayName string) (*

// DeleteServicePrincipal deletes a service principal.
func (c *AzureClient) DeleteServicePrincipal(ctx context.Context, objectID string) error {
log.Debugf("Deleting service principal with object id=%s", objectID)
mlog.Debug("Deleting service principal", "object id", objectID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto comment for all keys that have 2 words (should we use camel case key name?)

@@ -103,7 +188,7 @@ func (a *authArgs) Validate() error {
if err != nil || subID.String() == "00000000-0000-0000-0000-000000000000" {
return errors.New("--subscription-id is required (and must be a valid UUID)")
}
log.Infoln("No subscription provided, using selected subscription from Azure CLI:", subID.String())
mlog.Info("No subscription provided, using selected subscription from Azure CLI", "subscription-id", subID.String())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mlog.Info("No subscription provided, using selected subscription from Azure CLI", "subscription-id", subID.String())
mlog.Info("No subscription provided, using selected subscription from Azure CLI", "subscriptionID", subID.String())

nit:

@enj enj force-pushed the enj/i/mlog_migrate_logrus branch from 974e7af to 6d4313a Compare February 4, 2023 05:14
@enj
Copy link
Member Author

enj commented Feb 4, 2023

@aramase this should be ready now.

@enj enj merged commit 48230a8 into Azure:main Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate to JSON only logs with mlog
2 participants