Skip to content

Commit

Permalink
Fix logging disable issue
Browse files Browse the repository at this point in the history
  • Loading branch information
hlu2 committed Jun 20, 2018
1 parent f1b1db3 commit 2943e4d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
8 changes: 8 additions & 0 deletions src/Core/HttpClients/SyncRestHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ public function updateContext($newServiceContext){
}
}

/**
* Return the RequestLogger
* @return LogRequestsToDisk $requestLogger;
*/
public function getRequestLogger(){
return $this->RequestLogging;
}


/**
* Return an representation of an error returned by the last request, or false if the last request was not an error.
Expand Down
26 changes: 20 additions & 6 deletions src/DataService/DataService.php
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ public function useJson()
*/
public function setLogLocation($new_log_location)
{
$serviceContext = $this->getServiceContext();
$serviceContext->setLogLocation($new_log_location);
$this->updateServiceContextSettingsForOthers($serviceContext);
$restHandler = $this->restHandler;
$loggerUsedByRestHandler = $restHandler->getRequestLogger();
$loggerUsedByRestHandler->setLogDirectory($new_log_location);
return $this;
}

Expand All @@ -287,9 +287,22 @@ public function setMinorVersion($newMinorVersion)
*/
public function disableLog()
{
$serviceContext = $this->getServiceContext();
$serviceContext->disableLog();
$this->updateServiceContextSettingsForOthers($serviceContext);
$restHandler = $this->restHandler;
$loggerUsedByRestHandler = $restHandler->getRequestLogger();
$loggerUsedByRestHandler->setLogStatus(false);
return $this;
}

/**
* Enable the logging function
*
* @return $this
*/
public function enableLog()
{
$restHandler = $this->restHandler;
$loggerUsedByRestHandler = $restHandler->getRequestLogger();
$loggerUsedByRestHandler->setLogStatus(true);
return $this;
}

Expand All @@ -300,6 +313,7 @@ public function disableLog()
*/
public function throwExceptionOnError($bool){
$this->throwExceptionOnError = $bool;
return $this;
}

/**
Expand Down
18 changes: 17 additions & 1 deletion src/Diagnostics/LogRequestsToDisk.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,26 @@ class LogRequestsToDisk
*/
public function __construct($enableServiceRequestLogging=false, $serviceRequestLoggingLocation=null)
{
$this->EnableServiceRequestsLogging = (!empty($enableServiceRequestLogging) && ("false" !== strtolower(trim($enableServiceRequestLogging))));
$this->EnableServiceRequestsLogging = $enableServiceRequestLogging;
$this->ServiceRequestLoggingLocation = $serviceRequestLoggingLocation;
}

/**
* Enabled or disable the log
* @param Boolean $status
*/
public function setLogStatus($status){
$this->EnableServiceRequestsLogging = $status;
}

/**
* Set Log directory
* @param String $logDirectory
*/
public function setLogDirectory($logDirectory){
$this->ServiceRequestLoggingLocation = $logDirectory;
}

/**
* Gets the log destination folder
* @return string log destination folder
Expand Down

0 comments on commit 2943e4d

Please # to comment.