Skip to content

Commit 2943e4d

Browse files
committed
Fix logging disable issue
1 parent f1b1db3 commit 2943e4d

File tree

3 files changed

+45
-7
lines changed

3 files changed

+45
-7
lines changed

src/Core/HttpClients/SyncRestHandler.php

+8
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ public function updateContext($newServiceContext){
8282
}
8383
}
8484

85+
/**
86+
* Return the RequestLogger
87+
* @return LogRequestsToDisk $requestLogger;
88+
*/
89+
public function getRequestLogger(){
90+
return $this->RequestLogging;
91+
}
92+
8593

8694
/**
8795
* Return an representation of an error returned by the last request, or false if the last request was not an error.

src/DataService/DataService.php

+20-6
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ public function useJson()
259259
*/
260260
public function setLogLocation($new_log_location)
261261
{
262-
$serviceContext = $this->getServiceContext();
263-
$serviceContext->setLogLocation($new_log_location);
264-
$this->updateServiceContextSettingsForOthers($serviceContext);
262+
$restHandler = $this->restHandler;
263+
$loggerUsedByRestHandler = $restHandler->getRequestLogger();
264+
$loggerUsedByRestHandler->setLogDirectory($new_log_location);
265265
return $this;
266266
}
267267

@@ -287,9 +287,22 @@ public function setMinorVersion($newMinorVersion)
287287
*/
288288
public function disableLog()
289289
{
290-
$serviceContext = $this->getServiceContext();
291-
$serviceContext->disableLog();
292-
$this->updateServiceContextSettingsForOthers($serviceContext);
290+
$restHandler = $this->restHandler;
291+
$loggerUsedByRestHandler = $restHandler->getRequestLogger();
292+
$loggerUsedByRestHandler->setLogStatus(false);
293+
return $this;
294+
}
295+
296+
/**
297+
* Enable the logging function
298+
*
299+
* @return $this
300+
*/
301+
public function enableLog()
302+
{
303+
$restHandler = $this->restHandler;
304+
$loggerUsedByRestHandler = $restHandler->getRequestLogger();
305+
$loggerUsedByRestHandler->setLogStatus(true);
293306
return $this;
294307
}
295308

@@ -300,6 +313,7 @@ public function disableLog()
300313
*/
301314
public function throwExceptionOnError($bool){
302315
$this->throwExceptionOnError = $bool;
316+
return $this;
303317
}
304318

305319
/**

src/Diagnostics/LogRequestsToDisk.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,26 @@ class LogRequestsToDisk
3030
*/
3131
public function __construct($enableServiceRequestLogging=false, $serviceRequestLoggingLocation=null)
3232
{
33-
$this->EnableServiceRequestsLogging = (!empty($enableServiceRequestLogging) && ("false" !== strtolower(trim($enableServiceRequestLogging))));
33+
$this->EnableServiceRequestsLogging = $enableServiceRequestLogging;
3434
$this->ServiceRequestLoggingLocation = $serviceRequestLoggingLocation;
3535
}
3636

37+
/**
38+
* Enabled or disable the log
39+
* @param Boolean $status
40+
*/
41+
public function setLogStatus($status){
42+
$this->EnableServiceRequestsLogging = $status;
43+
}
44+
45+
/**
46+
* Set Log directory
47+
* @param String $logDirectory
48+
*/
49+
public function setLogDirectory($logDirectory){
50+
$this->ServiceRequestLoggingLocation = $logDirectory;
51+
}
52+
3753
/**
3854
* Gets the log destination folder
3955
* @return string log destination folder

0 commit comments

Comments
 (0)