-
Notifications
You must be signed in to change notification settings - Fork 850
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
Removed and renamed some content #15285
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,62 +6,41 @@ | |
package azcore | ||
|
||
import ( | ||
"github.com/Azure/azure-sdk-for-go/sdk/internal/logger" | ||
"github.com/Azure/azure-sdk-for-go/sdk/internal/log" | ||
) | ||
|
||
// LogClassification is used to group entries. Each group can be toggled on or off | ||
type LogClassification logger.LogClassification | ||
// LogClassification is used to group entries. Each group can be toggled on or off. | ||
type LogClassification = log.Classification | ||
|
||
const ( | ||
// LogRequest entries contain information about HTTP requests. | ||
// This includes information like the URL, query parameters, and headers. | ||
LogRequest LogClassification = "Request" | ||
LogRequest = log.Request | ||
|
||
// LogResponse entries contain information about HTTP responses. | ||
// This includes information like the HTTP status code, headers, and request URL. | ||
LogResponse LogClassification = "Response" | ||
LogResponse = log.Response | ||
|
||
// LogRetryPolicy entries contain information specific to the retry policy in use. | ||
LogRetryPolicy LogClassification = "RetryPolicy" | ||
LogRetryPolicy = log.RetryPolicy | ||
|
||
// LogLongRunningOperation entries contain information specific to long-running operations. | ||
// This includes information like polling location, operation state and sleep intervals. | ||
LogLongRunningOperation LogClassification = "LongRunningOperation" | ||
LogLongRunningOperation = log.LongRunningOperation | ||
) | ||
|
||
// SetClassifications is used to control which classifications are written to | ||
// LogSetClassifications is used to control which classifications are written to | ||
// the log. By default all log classifications are writen. | ||
func SetClassifications(cls ...LogClassification) { | ||
input := make([]logger.LogClassification, 0) | ||
for _, l := range cls { | ||
input = append(input, logger.LogClassification(l)) | ||
} | ||
logger.Log().SetClassifications(input...) | ||
} | ||
|
||
// Listener is the function signature invoked when writing log entries. | ||
// A Listener is required to perform its own synchronization if it's expected to be called | ||
// from multiple Go routines | ||
type Listener func(LogClassification, string) | ||
|
||
// transform to convert the azcore.Listener type into a usable one for internal.logger module | ||
func transform(lst Listener) logger.Listener { | ||
return func(l logger.LogClassification, msg string) { | ||
azcoreL := LogClassification(l) | ||
lst(azcoreL, msg) | ||
} | ||
func LogSetClassifications(cls ...LogClassification) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stuttering |
||
log.SetClassifications(cls...) | ||
} | ||
|
||
// SetListener will set the Logger to write to the specified Listener. | ||
func SetListener(lst Listener) { | ||
if lst == nil { | ||
logger.Log().SetListener(nil) | ||
} else { | ||
logger.Log().SetListener(transform(lst)) | ||
} | ||
func LogSetListener(lst func(log.Classification, string)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stuttering |
||
log.SetListener(lst) | ||
} | ||
|
||
// for testing purposes | ||
func resetClassifications() { | ||
logger.Log().SetClassifications([]logger.LogClassification{}...) | ||
log.TestResetClassifications() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You'll get stuttering here: log.LogRequest. How about RequestClassification, etc?
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.
This will be fixed in a subsequent PR to move logging to its own package (will post shortly).