From da19c496f92d0880fe0ca4644b27026184c67818 Mon Sep 17 00:00:00 2001 From: Chin Leung Date: Fri, 12 Mar 2021 14:24:01 -0500 Subject: [PATCH] Added option to log responses --- config/config.php | 13 +++++++++++++ src/Http/Response.php | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/config/config.php b/config/config.php index 8acf2ae..56601aa 100644 --- a/config/config.php +++ b/config/config.php @@ -27,6 +27,19 @@ 'pin' => env('CONVERGE_USER_PIN'), ], + /* + |-------------------------------------------------------------------------- + | Debugging + |-------------------------------------------------------------------------- + | + | Indicates if the responses of Converge should be logged. + | + */ + + 'debug' => [ + 'log' => env('CONVERGE_LOG', false), + ], + /* |-------------------------------------------------------------------------- | Demo Mode diff --git a/src/Http/Response.php b/src/Http/Response.php index 4db1ed5..aa8b9be 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -3,6 +3,7 @@ namespace ChinLeung\Converge\Http; use Illuminate\Http\Client\Response as ClientResponse; +use Illuminate\Support\Facades\Log; use Illuminate\Support\Str; use SimpleXMLElement; @@ -30,6 +31,11 @@ class Response public function __construct(ClientResponse $response) { $this->response = $response; + + if (config('converge.debug.log')) { + Log::debug(sprintf('Converge Response :: [%s]', $response->body())); + } + $this->xml = simplexml_load_string($response->body()); $this->throwException();