-
Notifications
You must be signed in to change notification settings - Fork 191
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
feat: add StdOutLogger and LoggingTrait #578
base: main
Are you sure you want to change the base?
Conversation
4122fb0
to
6370690
Compare
$requestEvent->retryAttempt = $options['retryAttempt'] ?? null; | ||
$requestEvent->serviceName = $options['serviceName'] ?? null; | ||
$requestEvent->clientId = spl_object_id($this->client); | ||
$requestEvent->requestId = spl_object_id($request); |
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.
since this code is duplicated above, why not have private methods like logHttpRequest($request)
and logHttpResponse($response, $requestEvent)
?
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.
In my mind, formatting the LogEvent
and filling that data is not duty of the log
function. The log
function takes the generic log object and turns it into a json
string to the docs specification, that's why I decided to have this code "duplicated", which in my mind is not really "duplicated" but is basically the same, mostly because one is for the response and one is for the request, and I did it this way in order to keep them separate from the logging logic.
I also thought perhaps a function to make a logEvent
but voted against it as it would have to be flexible enough to acomodate the small differences between response
and request
but it can definitely be done.
016dad1
to
706982b
Compare
de8b6ff
to
db765ec
Compare
related: googleapis/gax-php#585
Add logging support to the HTTP calls for easy debugging.