Ejemplo n.º 1
0
 private function log($logLevelPrefix, $logMessage, $flags)
 {
     if (!$this->logFile) {
         return;
     }
     //masking
     $logMessage = $this->getMasked($logMessage);
     //debug_backtrace
     $fileName = 'n/a';
     $methodName = 'n/a';
     $lineNumber = 'n/a';
     $debugTrace = debug_backtrace();
     if (isset($debugTrace[1])) {
         $fileName = $debugTrace[1]['file'] ? $debugTrace[1]['file'] : 'n/a';
         $lineNumber = $debugTrace[1]['line'] ? $debugTrace[1]['line'] : 'n/a';
     }
     if (isset($debugTrace[2])) {
         $methodName = $debugTrace[2]['function'] ? $debugTrace[2]['function'] : 'n/a';
     }
     //Add timestamp, log level, method, file, line
     $logString = sprintf("\n %s %s : [%s] (%s : %s) - %s", \net\authorize\util\Helpers::now(), $logLevelPrefix, $methodName, $fileName, $lineNumber, $logMessage);
     file_put_contents($this->logFile, $logString, $flags);
 }
Ejemplo n.º 2
0
 /**
  * @param apiContract\ANetApiResponseType $response
  */
 protected static function displayMessages(apiContract\ANetApiResponseType $response)
 {
     if (null != $response) {
         $logMessage = sprintf("\n%s: Controller Response is not null, iterating messages.", \net\authorize\util\Helpers::now());
         echo $logMessage;
         file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
         $msgCount = 0;
         $allMessages = $response->getMessages();
         if (null != $allMessages) {
             $logMessage = sprintf("\n%s: Controller ResultCode: '%s'.", \net\authorize\util\Helpers::now(), $allMessages->getResultCode());
             echo $logMessage;
             file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
             if (null != $allMessages->getMessage()) {
                 foreach ($allMessages->getMessage() as $message) {
                     $msgCount++;
                     $logMessage = sprintf("\n%d - Message, Code: '%s', Text: '%s'", $msgCount, $message->getCode(), $message->getText());
                     echo $logMessage;
                     file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
                 }
             }
         }
         $logMessage = sprintf("\n%s: Controller Response contains '%d' messages.", \net\authorize\util\Helpers::now(), $msgCount);
         echo $logMessage;
         file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
     } else {
         $logMessage = sprintf("\n%s: Response is null.", \net\authorize\util\Helpers::now());
         echo $logMessage;
         file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
     }
 }
 function displayTransactionMessages(apiContract\CreateTransactionResponse $response)
 {
     if (null != $response) {
         $logMessage = sprintf("\n%s: Displaying Transaction Response.", \net\authorize\util\Helpers::now());
         echo $logMessage;
         file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
         if (null != $response->getTransactionResponse()) {
             $logMessage = sprintf("\n%s: Transaction Response Code: '%s'.", \net\authorize\util\Helpers::now(), $response->getTransactionResponse()->getResponseCode());
             echo $logMessage;
             file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
             $allMessages = $response->getTransactionResponse()->getMessages();
             $allErrors = $response->getTransactionResponse()->getErrors();
             $errorCount = 0;
             if (null != $allErrors) {
                 foreach ($allErrors as $error) {
                     $errorCount++;
                     $logMessage = sprintf("\n%s: %d - Error: Code:'%s', Text:'%s'", \net\authorize\util\Helpers::now(), $errorCount, $error->getErrorCode(), $error->getErrorText());
                     echo $logMessage;
                     file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
                 }
             }
             $messageCount = 0;
             if (null != $allMessages) {
                 foreach ($allMessages as $message) {
                     $messageCount++;
                     //$logMessage = sprintf("\n%s: %d - Message: Code:'%s', Description:'%s'", \net\authorize\util\Helpers::now(), $errorCount, $message->getCode(), $message->getDescription());
                     $logMessage = sprintf("\n%s: %d - Message: ", \net\authorize\util\Helpers::now(), $messageCount);
                     echo $logMessage;
                     file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
                 }
             }
             $logMessage = sprintf("\n%s: Transaction Response, Errors: '%d', Messages: '%d'.", \net\authorize\util\Helpers::now(), $errorCount, $messageCount);
             echo $logMessage;
             file_put_contents(self::$log_file, $logMessage, FILE_APPEND);
         }
     }
 }