Replies: 1 comment
-
@squatto Couldn't you do something like this and override the function ray(...$args) {
$settings = SettingsFactory::createFromConfigFile();
if (Ray::$enabled) {
return (new Ray($settings))->send(...$args);
}
info($args);
return new Ray($settings);
}
ray($response->json()); You could also create a custom Ray class and override the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
My idea will make more sense with an example for context:
$response
is the return from the Laravel HTTP client. When the request fails, I send the JSON throughray()
if Ray is enabled (e.g. because it's onlocal
). If Ray is disabled (e.g. because it's onproduction
), I still want to log the JSON response, so I send it throughinfo()
. Thisif (ray()->enabled()) { ... } else { ... }
process lets me keepray()
calls in code pushed to production (where Ray is disabled) and continue receiving log output whenever necessary.It would be very helpful to be able to only do the
ray()
call, and if Ray is disabled, have the option to pass the payload output to a logger that is configured inray.php
(any PSR-3 compliant logger)This would likely necessitate some payloads having a "simplified" formatter - one whose output could be easily saved to a text-based log file, for example. For most of the payloads this would be pretty trivial to accomplish. I'd imagine that most (if not all) payloads could just send
$payload->toArray()
to the relevant log method. If necessary, the payloads could override a method from\Spatie\Ray\Payloads\Payload
(like they do now withgetContent()
) if a different payload format is necessary/desired. Something likegetContentForLogger()
that by default just returns$this->toArray()
, maybe?Thanks!
Beta Was this translation helpful? Give feedback.
All reactions