jenkins-bot has submitted this change and it was merged.

Change subject: Use PSR logging in gateway adapters
......................................................................


Use PSR logging in gateway adapters

Can get rid of shortcut log functions after fixing up GatewayPage classes.

Bug: T86266
Change-Id: I0cc0115455d0e456a19390a00774e72864c6fde8
---
M adyen_gateway/adyen.adapter.php
M amazon_gateway/amazon.adapter.php
M gateway_common/gateway.adapter.php
M globalcollect_gateway/globalcollect.adapter.php
M globalcollect_gateway/scripts/orphan_adapter.php
M globalcollect_gateway/scripts/orphans.php
M tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
M tests/Adapter/GlobalCollect/GlobalCollectTest.php
M tests/Adapter/WorldPay/WorldPayTest.php
M tests/DonationInterfaceTestCase.php
M tests/IntegrationTest.php
M worldpay_gateway/worldpay.adapter.php
12 files changed, 185 insertions(+), 208 deletions(-)

Approvals:
  Awight: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/adyen_gateway/adyen.adapter.php b/adyen_gateway/adyen.adapter.php
index cb0afa7..dbb43af 100644
--- a/adyen_gateway/adyen.adapter.php
+++ b/adyen_gateway/adyen.adapter.php
@@ -203,7 +203,7 @@
                                        $this->addRequestData( array ( 
'risk_score' => $this->risk_score ) ); //this will also fire off staging again.
                                        if ( $this->getValidationAction() != 
'process' ) {
                                                // copied from base class.
-                                               $this->log( "Failed pre-process 
checks for transaction type $transaction.", LOG_INFO );
+                                               $this->logger->info( "Failed 
pre-process checks for transaction type $transaction." );
                                                $this->setTransactionResult( 
array(
                                                        'status' => false,
                                                        'message' => 
$this->getErrorMapByCodeAndTranslate( 'internal-0000' ),
@@ -221,7 +221,7 @@
                                                'data'
                                        );
                                        $requestParams = 
$this->buildRequestParams();
-                                       $this->log( "launching external iframe 
request: " . print_r( $requestParams, true )
+                                       $this->logger->info( "launching 
external iframe request: " . print_r( $requestParams, true )
                                        );
                                        $this->setTransactionResult(
                                                $requestParams,
@@ -479,13 +479,13 @@
                if ( $response === NULL ) { // convert GET data
                        $request_vars = $_GET;
 
-                       $this->log( "Processing user return data: " . print_r( 
$request_vars, TRUE ) );
+                       $this->logger->info( "Processing user return data: " . 
print_r( $request_vars, TRUE ) );
 
                        if ( !$this->checkResponseSignature( $request_vars ) ) {
-                               $this->log( "Bad signature in response" );
+                               $this->logger->info( "Bad signature in 
response" );
                                return 'BAD_SIGNATURE';
                        } else {
-                               $this->log( "Good signature", LOG_DEBUG );
+                               $this->logger->debug( "Good signature" );
                        }
 
                        $gateway_txn_id = isset( $request_vars[ 'pspReference' 
] ) ? $request_vars[ 'pspReference' ] : '';
@@ -494,11 +494,11 @@
                        if ( $result_code == 'PENDING' || $result_code == 
'AUTHORISED' ) {
                                // Both of these are listed as pending because 
we have to submit a capture
                                // request on 'AUTHORIZATION' ipn message 
receipt.
-                               $this->log( "User came back as pending or 
authorised, placing in pending queue" );
+                               $this->logger->info( "User came back as pending 
or authorised, placing in pending queue" );
                                $this->finalizeInternalStatus( 'pending' );
                        }
                        else {
-                               $this->log( "Negative response from gateway. 
Full response: " . print_r( $request_vars, TRUE ) );
+                               $this->logger->info( "Negative response from 
gateway. Full response: " . print_r( $request_vars, TRUE ) );
                                $this->finalizeInternalStatus( 'failed' );
                                return 'UNKNOWN';
                        }
@@ -508,7 +508,7 @@
                        $this->doLimboStompTransaction( TRUE ); // add 
antimessage
                        return null;
                }
-               $this->log( "No response from gateway" );
+               $this->logger->info( "No response from gateway" );
                return 'NO_RESPONSE';
        }
 
diff --git a/amazon_gateway/amazon.adapter.php 
b/amazon_gateway/amazon.adapter.php
index 47b9732..1bf0acf 100644
--- a/amazon_gateway/amazon.adapter.php
+++ b/amazon_gateway/amazon.adapter.php
@@ -230,7 +230,7 @@
                        unset( $request_params[ 'title' ] );
                        $incoming = http_build_query( $request_params, '', '&' 
);
                        $this->transactions[ $transaction ][ 'values' ][ 
'HttpParameters' ] = $incoming;
-                       $this->log( "received callback from amazon with: 
$incoming", LOG_DEBUG );
+                       $this->logger->debug( "received callback from amazon 
with: $incoming" );
                        break;
                }
 
@@ -243,7 +243,7 @@
                        case 'Donate':
                        case 'DonateMonthly':
                                $query_str = $this->encodeQuery( $query );
-                               $this->log( "At $transaction, redirecting with 
query string: $query_str", LOG_DEBUG );
+                               $this->logger->debug( "At $transaction, 
redirecting with query string: $query_str" );
                                
                                //always have to do this before a redirect. 
                                $this->dataObj->saveContributionTrackingData();
@@ -259,7 +259,7 @@
                                $query_str = $this->encodeQuery( $query );
                                $this->url .= 
"?{$query_str}&Signature={$signature}";
 
-                               $this->log( "At $transaction, query string: 
$query_str", LOG_DEBUG );
+                               $this->logger->debug( "At $transaction, query 
string: $query_str" );
 
                                parent::do_transaction( $transaction );
 
@@ -277,7 +277,7 @@
                                break;
 
                        default:
-                               $this->log( "At $transaction; THIS IS NOT 
DEFINED!", LOG_CRIT );
+                               $this->logger->critical( "At $transaction; THIS 
IS NOT DEFINED!" );
                                $this->finalizeInternalStatus( 'failed' );
                }
 
@@ -310,7 +310,7 @@
                                // We will however log it if we have a 
seemingly valid transaction id
                                if ( $txnid != null ) {
                                        $ctid = 
$this->getData_Unstaged_Escaped( 'contribution_tracking_id' );
-                                       $this->log( "$ctid failed orderid 
verification but has txnid '$txnid'. Investigation required.", LOG_ALERT );
+                                       $this->logger->alert( "$ctid failed 
orderid verification but has txnid '$txnid'. Investigation required." );
                                        if ( $this->getGlobal( 
'UseOrderIdValidation' ) ) {
                                                $this->finalizeInternalStatus( 
'failed' );
                                                return;
@@ -325,7 +325,7 @@
                        // about the transaction.
                        // todo: lots of other statuses we can interpret
                        // see: 
http://docs.amazonwebservices.com/AmazonSimplePay/latest/ASPAdvancedUserGuide/ReturnValueStatusCodes.html
-                       $this->log( "Transaction $txnid returned with status " 
. $this->dataObj->getVal_Escaped( 'gateway_status' ), LOG_INFO );
+                       $this->logger->info( "Transaction $txnid returned with 
status " . $this->dataObj->getVal_Escaped( 'gateway_status' ) );
                        switch ( $this->dataObj->getVal_Escaped( 
'gateway_status' ) ) {
                                case 'PS':  // Payment success
                                        $this->finalizeInternalStatus( 
'complete' );
@@ -351,12 +351,12 @@
                                default:        // All other errorz
                                        $status = 
$this->dataObj->getVal_Escaped( 'gateway_status' );
                                        $errString = 
$this->dataObj->getVal_Escaped( 'error_message' );
-                                       $this->log( "Transaction $txnid failed 
with ($status) $errString", LOG_INFO );
+                                       $this->logger->info( "Transaction 
$txnid failed with ($status) $errString" );
                                        $this->finalizeInternalStatus( 'failed' 
);
                                        break;
                        }
                } else {
-                       $this->log( 'Apparently we attempted to process a 
transaction that already had a final status... Odd', LOG_ERR );
+                       $this->logger->error( 'Apparently we attempted to 
process a transaction that already had a final status... Odd' );
                }
        }
 
@@ -394,7 +394,7 @@
                                                        
$add_data['payment_submethod'] = $submethods[$value];
                                                } else {
                                                        //We don't rely on this 
anywhere serious, but I want to know about it anyway.
-                                                       $this->log( "Amazon 
just coughed up a surprise payment submethod of '$value'.", LOG_ERR );
+                                                       $this->logger->error( 
"Amazon just coughed up a surprise payment submethod of '$value'." );
                                                        
$add_data['payment_submethod'] = 'unknown';
                                                }
                                                break;
@@ -410,12 +410,12 @@
                $txnid = $this->dataObj->getVal_Escaped( 'gateway_txn_id' );
                $email = $this->dataObj->getVal_Escaped( 'email' );
 
-               $this->log( "Added data to session for txnid $txnid. Now 
serving email $email.", LOG_INFO );
+               $this->logger->info( "Added data to session for txnid $txnid. 
Now serving email $email." );
        }
 
        function processResponse( $response, &$retryVars = null ) {
                if ( ( $this->getCurrentTransaction() == 'VerifySignature' ) && 
( $response['data'] == true ) ) {
-                       $this->log( "Transaction failed in response data 
verification.", LOG_INFO );
+                       $this->logger->info( "Transaction failed in response 
data verification." );
                        $this->finalizeInternalStatus( 'failed' );
                }
        }
diff --git a/gateway_common/gateway.adapter.php 
b/gateway_common/gateway.adapter.php
index 514dde2..f2c6af8 100644
--- a/gateway_common/gateway.adapter.php
+++ b/gateway_common/gateway.adapter.php
@@ -244,6 +244,24 @@
        protected $dataObj;
 
        /**
+        * Standard logger, logs to {type}_gateway
+        * @var \Psr\Log\LoggerInterface
+        */
+       protected $logger;
+
+       /**
+        * Logs to {type}_gateway_commstats
+        * @var \Psr\Log\LoggerInterface
+        */
+       protected $commstats_logger;
+
+       /**
+        * Logs to {type}_gateway_payment_init
+        * @var \Psr\Log\LoggerInterface
+        */
+       protected $payment_init_logger;
+
+       /**
         * $transaction_results is the member var that keeps track of the 
results of
         * the latest discrete transaction with the gateway.
         * There could be multiple transaction with the gateway in any one 
donation.
@@ -333,6 +351,10 @@
                        $this->batch = $options['batch_mode'];
                        unset( $options['batch_mode'] );
                }
+
+               $this->logger = DonationLoggerFactory::getLogger( $this );
+               $this->commstats_logger = DonationLoggerFactory::getLogger( 
$this, '_commstats' );
+               $this->payment_init_logger = DonationLoggerFactory::getLogger( 
$this, '_payment_init' );
 
                if ( !self::getGlobal( 'Test' ) ) {
                        $this->url = self::getGlobal( 'URL' );
@@ -439,7 +461,7 @@
                        try {
                                $fail_ffname = 
GatewayFormChooser::getBestErrorForm( $data['gateway'], 
$data['payment_method'], $data['payment_submethod'] );
                        } catch ( Exception $e ) {
-                               $this->log( 'Cannot determine best error form. 
' . $e->getMessage(), LOG_ERR );
+                               $this->logger->error( 'Cannot determine best 
error form. ' . $e->getMessage() );
                        }
 
                        return GatewayFormChooser::buildPaymentsFormURL( 
$fail_ffname, $this->getRetryData() );
@@ -729,7 +751,7 @@
        protected function getTransactionSpecificValue( $gateway_field_name, 
$token = false ) {
                if ( empty( $this->transactions ) ) {
                        $msg = self::getGatewayName() . ': Transactions 
structure is empty! No transaction can be constructed.';
-                       $this->log( $msg, LOG_CRIT );
+                       $this->logger->critical( $msg );
                        throw new MWException( $msg );
                }
                //Ensures we are using the correct transaction structure for 
our various lookups.
@@ -772,7 +794,7 @@
                //not in the map, or hard coded. What then?
                //Complain furiously, for your code is faulty.
                $msg = self::getGatewayName() . ': Requested value ' . 
$gateway_field_name . ' cannot be found in the transactions structure.';
-               $this->log( $msg, LOG_CRIT );
+               $this->logger->critical( $msg );
                throw new MWException( $msg );
        }
 
@@ -794,7 +816,7 @@
                        !array_key_exists( 'request', 
$this->transactions[$transaction] ) ) {
 
                        $msg = self::getGatewayName() . ": $transaction request 
structure is empty! No transaction can be constructed.";
-                       $this->log( $msg, LOG_CRIT );
+                       $this->logger->critical( $msg );
                        throw new MWException( $msg );
                }
 
@@ -871,7 +893,7 @@
                                //...safe zone.
                                $logme = $return;
                        }
-                       $this->log( $message . $logme );
+                       $this->logger->info( $message . $logme );
                }
 
 
@@ -983,7 +1005,7 @@
                                'message' => 'Failed data validation',
                                'errors' => $this->getAllErrors(),
                        );
-                       $this->log( "Failed Validation. Aborting $transaction " 
. print_r( $this->getValidationErrors(), true ) );
+                       $this->logger->info( "Failed Validation. Aborting 
$transaction " . print_r( $this->getValidationErrors(), true ) );
                        return $return;
                }
 
@@ -997,7 +1019,7 @@
                                // TODO: Add more intelligence here. Right now 
we just assume it's the order_id
                                // and that it is totally OK to just reset it 
and reroll.
 
-                               $this->log( "Repeating transaction on request 
for vars: " . implode( ',', $retryVars ) );
+                               $this->logger->info( "Repeating transaction on 
request for vars: " . implode( ',', $retryVars ) );
 
                                // Force regen of the order_id
                                $this->regenerateOrderID();
@@ -1011,7 +1033,7 @@
                } while ( ( !empty( $retryVars ) ) && ( ++$retryCount < 3 ) );
 
                if ( $retryCount >= 3 ) {
-                       $this->log( "Transaction canceled after $retryCount 
retries.", LOG_ERR );
+                       $this->logger->error( "Transaction canceled after 
$retryCount retries." );
                }
 
                return $retval;
@@ -1052,7 +1074,7 @@
 
                        $this->executeIfFunctionExists( 'pre_process_' . 
$transaction );
                        if ( $this->getValidationAction() != 'process' ) {
-                               $this->log( "Failed pre-process checks for 
transaction type $transaction.", LOG_INFO );
+                               $this->logger->info( "Failed pre-process checks 
for transaction type $transaction." );
                                $this->setTransactionResult(
                                        array(
                                                'status' => false,
@@ -1100,7 +1122,7 @@
                                throw new MWException( "Communication type of 
'{$commType}' unknown" );
                        }
                } catch ( MWException $e ) {
-                       $this->log( "Malformed gateway definition. Cannot 
continue: Aborting.\n" . $e->getMessage(), LOG_CRIT );
+                       $this->logger->critical( "Malformed gateway definition. 
Cannot continue: Aborting.\n" . $e->getMessage() );
 
                        $this->setTransactionResult( array(
                                'status' => false,
@@ -1118,7 +1140,7 @@
                $this->getStopwatch( __FUNCTION__, true );
                $txn_ok = $this->curl_transaction( $curlme );
                if ( $txn_ok === true ) { //We have something to slice and dice.
-                       $this->log( "RETURNED FROM CURL:" . print_r( 
$this->getTransactionAllResults(), true ) );
+                       $this->logger->info( "RETURNED FROM CURL:" . print_r( 
$this->getTransactionAllResults(), true ) );
 
                        //set the status of the response. This is the 
COMMUNICATION status, and has nothing
                        //to do with the result of the transaction.
@@ -1140,7 +1162,7 @@
                        $this->setTransactionResult( 
$this->getValidationAction(), 'action' );
 
                } elseif ( $txn_ok === false ) { //nothing to process, so we 
have to build it manually
-                       $this->log( "Transaction Communication failed" . 
print_r( $this->getTransactionAllResults(), true ), LOG_ERR );
+                       $this->logger->error( "Transaction Communication 
failed" . print_r( $this->getTransactionAllResults(), true ) );
 
                        $this->setTransactionResult( array(
                                'status' => false,
@@ -1156,7 +1178,7 @@
                $this->saveCommunicationStats( __FUNCTION__, $transaction );
 
                if ( !empty( $retryVars ) ) {
-                       $this->log( "$transaction Communication failed (errcode 
$errCode), will reattempt!", LOG_CRIT );
+                       $this->logger->critical( "$transaction Communication 
failed (errcode $errCode), will reattempt!" );
 
                        // Set this by key so that the result object still has 
all the cURL data
                        $this->setTransactionResult( false, 'status' );
@@ -1180,7 +1202,7 @@
                if ( $txn_ok && empty( $retryVars ) ) {
                        $this->executeIfFunctionExists( 'post_process_' . 
$transaction );
                        if ( $this->getValidationAction() != 'process' ) {
-                               $this->log( "Failed post-process checks for 
transaction type $transaction.", LOG_INFO );
+                               $this->logger->info( "Failed post-process 
checks for transaction type $transaction." );
                                $this->setTransactionResult(
                                        array(
                                                'status' => false,
@@ -1196,7 +1218,7 @@
                }
 
                // log that the transaction is essentially complete
-               $this->log( " Transaction complete." );
+               $this->logger->info( " Transaction complete." );
 
                $this->debugarray[] = 'numAttempt = ' . self::session_getData( 
'numAttempt' );
 
@@ -1244,7 +1266,7 @@
        public function setCurrentTransaction( $transaction_name ){
                if ( empty( $this->transactions ) || !is_array( 
$this->transactions ) || !array_key_exists( $transaction_name, 
$this->transactions ) ) {
                        $msg = self::getGatewayName() . ': Transaction Name "' 
. $transaction_name . '" undefined for this gateway.';
-                       $this->log( $msg, LOG_ALERT );
+                       $this->logger->alert( $msg );
                        throw new MWException( $msg );
                } else {
                        $this->current_transaction = $transaction_name;
@@ -1355,14 +1377,14 @@
                 * email address. If the cURL function fails, we lose the 
ability to do
                 * that association outside of this log line.
                 */
-               $this->log( "Initiating cURL for donor $email" );
+               $this->logger->info( "Initiating cURL for donor $email" );
 
                // Initialize cURL and construct operation (also run hook)
                $ch = curl_init();
 
                $hookResult = WmfFramework::runHooks( 
'DonationInterfaceCurlInit', array( &$this ) );
                if ( $hookResult == false ) {
-                       $this->log( 'cURL transaction aborted on hook 
DonationInterfaceCurlInit', LOG_INFO );
+                       $this->logger->info( 'cURL transaction aborted on hook 
DonationInterfaceCurlInit' );
                        $this->setValidationAction('reject');
                        return false;
                }
@@ -1385,7 +1407,7 @@
                $results = array();
 
                while ( ( $i++ <= 3 ) && ( $continue === true )) {
-                       $this->log( "Preparing to send 
{$this->getCurrentTransaction()} transaction to $gatewayName" );
+                       $this->logger->info( "Preparing to send 
{$this->getCurrentTransaction()} transaction to $gatewayName" );
 
                        // Execute the cURL operation
                        $result = $this->curl_exec( $ch );
@@ -1401,7 +1423,7 @@
                                        case 200:   // Everything is AWESOME
                                                $continue = false;
 
-                                               $this->log( "Successful 
transaction to $gatewayName", LOG_DEBUG );
+                                               $this->logger->debug( 
"Successful transaction to $gatewayName" );
                                                $this->setTransactionResult( 
$results );
 
                                                $retval = true;
@@ -1410,7 +1432,7 @@
                                        case 400:   // Oh noes! Bad request.. 
BAD CODE, BAD BAD CODE!
                                                $continue = false;
 
-                                               $this->log( "$gatewayName 
returned (400) BAD REQUEST: $result", LOG_ERR );
+                                               $this->logger->error( 
"$gatewayName returned (400) BAD REQUEST: $result" );
 
                                                // Even though there was an 
error, set the results. Amazon at least gives
                                                // us useful XML return
@@ -1421,12 +1443,12 @@
 
                                        case 403:   // Hmm, forbidden? Maybe if 
we ask it nicely again...
                                                $continue = true;
-                                               $this->log( "$gatewayName 
returned (403) FORBIDDEN: $result", LOG_ALERT );
+                                               $this->logger->alert( 
"$gatewayName returned (403) FORBIDDEN: $result" );
                                                break;
 
                                        default:    // No clue what happened... 
break out and log it
                                                $continue = false;
-                                               $this->log( "$gatewayName 
failed remotely and returned ($httpCode): $result", LOG_ERR );
+                                               $this->logger->error( 
"$gatewayName failed remotely and returned ($httpCode): $result" );
                                                break;
                                }
                        } else {
@@ -1435,7 +1457,7 @@
 
                                $errno = $this->curl_errno( $ch );
                                $err = curl_error( $ch );
-                               $this->log( "cURL transaction  to $gatewayName 
failed: ($errno) $err", LOG_ALERT );
+                               $this->logger->alert( "cURL transaction  to 
$gatewayName failed: ($errno) $err" );
                        }
 
                } // End while cURL transaction hasn't returned something useful
@@ -1489,7 +1511,7 @@
                        //DO NOT alter the line below unless you are prepared 
to also alter the GC audit scripts.
                        //...and everything that references "Raw XML Response"
                        //@TODO: All three of those things.
-                       $this->log( "Raw XML Response:\n" . $displayXML ); //I 
am apparently a huge fibber.
+                       $this->logger->info( "Raw XML Response:\n" . 
$displayXML ); //I am apparently a huge fibber.
                        $realXML->loadXML( trim( $xmlString ) );
                        return $realXML;
                }
@@ -1505,7 +1527,7 @@
                                $responseArray[ $key ] = $value;
                        }
 
-                       $this->log( "Here is the response as an array: " . 
print_r( $responseArray, true ) );
+                       $this->logger->info( "Here is the response as an array: 
" . print_r( $responseArray, true ) );
                        return $responseArray;
                }
        }
@@ -1518,7 +1540,7 @@
                        $xmlStart = strpos( $rawResponse, '<' );
                }
                if ( $xmlStart === false ) { //Still false. Your Head Asplode.
-                       $this->log( "Completely Mangled Response:\n" . 
$rawResponse, LOG_ERR );
+                       $this->logger->error( "Completely Mangled Response:\n" 
. $rawResponse );
                        return false;
                }
                $justXML = substr( $rawResponse, $xmlStart );
@@ -1678,7 +1700,7 @@
                        $start[$string] = $now;
                }
                $clock = round( $now - $start[$string], 4 );
-               $this->log( "Clock at $string: $clock ($now)" );
+               $this->logger->info( "Clock at $string: $clock ($now)" );
                return $clock;
        }
 
@@ -1731,7 +1753,7 @@
                        foreach ($params as $key=>$val){
                                $msg .= "$key:$val - ";
                        }
-                       $this->log( $msg, LOG_INFO, '_commstats' );
+                       $this->commstats_logger->info( $msg );
                }
        }
 
@@ -1872,14 +1894,14 @@
 
                        default:
                                // No action
-                               $this->log( "STOMP transaction has no place to 
go for status $status. This is probably completely normal." );
+                               $this->logger->info( "STOMP transaction has no 
place to go for status $status. This is probably completely normal." );
                                return;
                }
 
                try {
                        WmfFramework::runHooks( 'gwStomp', array( $transaction, 
$queue ) );
                } catch ( Exception $e ) {
-                       $this->log( "STOMP ERROR. Could not add message to 
'{$queue}' queue: {$e->getMessage()} " . json_encode( $transaction ), LOG_CRIT 
);
+                       $this->logger->critical( "STOMP ERROR. Could not add 
message to '{$queue}' queue: {$e->getMessage()} " . json_encode( $transaction ) 
);
                }
        }
 
@@ -1906,7 +1928,7 @@
                try {
                        WmfFramework::runHooks( 'gwStomp', array( $transaction, 
'limbo' ) );
                } catch ( Exception $e ) {
-                       $this->log( "STOMP ERROR. Could not add message to 
'limbo' queue: {$e->getMessage()} " . json_encode( $transaction ), LOG_CRIT );
+                       $this->logger->critical( "STOMP ERROR. Could not add 
message to 'limbo' queue: {$e->getMessage()} " . json_encode( $transaction ) );
                }
        }
 
@@ -1970,7 +1992,7 @@
         */
        public function makeFreeformStompTransaction( $transaction ) {
                if ( !array_key_exists( 'php-message-class', $transaction ) ) {
-                       $this->log( "Trying to send a freeform STOMP message 
with no class defined. Bad programmer.", LOG_WARNING );
+                       $this->logger->warning( "Trying to send a freeform 
STOMP message with no class defined. Bad programmer." );
                        $transaction['php-message-class'] = 
'undefined-loser-message';
                }
 
@@ -2077,7 +2099,7 @@
                                }
 
                        } else {
-                               //$this->log( 'Field does not exist in 
$this->dataConstraints[ ' . ( string ) $field . ' ]', LOG_DEBUG );
+                               //$this->logger->debug( 'Field does not exist 
in $this->dataConstraints[ ' . ( string ) $field . ' ]' );
                        }
 
                        $this->staged_data[ $field ] = $value;
@@ -2363,7 +2385,7 @@
                        $msg .= " $txn_message";
                }
 
-               $this->log( $msg, LOG_INFO, '_payment_init' );
+               $this->payment_init_logger->info( $msg );
        }
 
        public function sendFinalStatusMessage( $status ) {
@@ -2392,7 +2414,7 @@
                try {
                        WmfFramework::runHooks( 'gwFreeformStomp', array ( 
$transaction, 'payments-init' ) );
                } catch ( Exception $e ) {
-                       $this->log( 'Unable to send payments-init message', 
LOG_ERR );
+                       $this->logger->error( 'Unable to send payments-init 
message' );
                }
        }
 
@@ -2526,13 +2548,13 @@
                //extra layer of Stop Doing This.
                $errors = $this->getTransactionErrors();
                if ( !empty( $errors ) ) {
-                       $this->log( 'Skipping antifraud hooks: Transaction is 
already in error' );
+                       $this->logger->info( 'Skipping antifraud hooks: 
Transaction is already in error' );
                        return;
                }
                // allow any external validators to have their way with the data
-               $this->log( 'Preparing to run custom filters' );
+               $this->logger->info( 'Preparing to run custom filters' );
                WmfFramework::runHooks( 'GatewayValidate', array( &$this ) );
-               $this->log( 'Finished running custom filters' );
+               $this->logger->info( 'Finished running custom filters' );
 
                //DO NOT set some variable as getValidationAction() here, and 
keep
                //checking that. getValidationAction could change with each one 
of these
@@ -2756,7 +2778,7 @@
                                                );
                                                break;
                                        default:
-                                               $this->log( "bad required group 
name: {$type}", LOG_ERR );
+                                               $this->logger->error( "bad 
required group name: {$type}" );
                                                continue;
                                }
 
@@ -2819,7 +2841,7 @@
                $msg = self::getGatewayName() . ': Country map: '
                        . print_r( $countryMap, true );
 
-               $this->log( $msg, LOG_DEBUG );
+               $this->logger->debug( $msg );
 
                // Lookup a score if it is defined
                if ( isset( $countryMap[ $country ] ) ) {
@@ -2861,7 +2883,7 @@
                $msg = self::getGatewayName() . ': Email Domain map: '
                        . print_r( $emailDomainMap, true );
 
-               $this->log( $msg, LOG_DEBUG );
+               $this->logger->debug( $msg );
 
                // Lookup a score if it is defined
                if ( isset( $emailDomainMap[ $emailDomain ] ) ) {
@@ -2901,7 +2923,7 @@
                $msg = self::getGatewayName() . ': UTM Campaign map: '
                        . print_r( $campaignMap, true );
 
-               $this->log( $msg, LOG_DEBUG );
+               $this->logger->debug( $msg );
 
                // If any of the defined regex patterns match, add the points.
                if ( is_array( $campaignMap ) && !empty( $campaignMap ) ){
@@ -2945,7 +2967,7 @@
                $msg = self::getGatewayName() . ': UTM Medium map: '
                        . print_r( $mediumMap, true );
 
-               $this->log( $msg, LOG_DEBUG );
+               $this->logger->debug( $msg );
 
                // If any of the defined regex patterns match, add the points.
                if ( is_array( $mediumMap ) && !empty( $mediumMap ) ){
@@ -2988,7 +3010,7 @@
                $msg = self::getGatewayName() . ': UTM Source map: '
                        . print_r( $sourceMap, true );
 
-               $this->log( $msg, LOG_DEBUG );
+               $this->logger->debug( $msg );
 
                // If any of the defined regex patterns match, add the points.
                if ( is_array( $sourceMap ) && !empty( $sourceMap ) ){
@@ -3102,7 +3124,7 @@
         * This will be used internally every time we call do_transaction.
         */
        public function session_addDonorData() {
-               $this->log( __FUNCTION__ . ': Refreshing all donor data', 
LOG_INFO );
+               $this->logger->info( __FUNCTION__ . ': Refreshing all donor 
data' );
                self::session_ensure();
                $_SESSION['Donor'] = array ( );
                $donordata = DonationData::getStompMessageFields();
@@ -3157,7 +3179,7 @@
                }
 
                if ( $reset ) {
-                       $this->log( __FUNCTION__ . ': Unsetting session donor 
data', LOG_INFO );
+                       $this->logger->info( __FUNCTION__ . ': Unsetting 
session donor data' );
                        $this->session_unsetDonorData();
                        //leave the payment forms and antifraud data alone.
                        //but, under no circumstances should the gateway edit
@@ -3176,7 +3198,7 @@
                                }
                        }
                        if ( $msg != '' ) {
-                               $this->log( __FUNCTION__ . ": Unset the 
following session keys: $msg", LOG_INFO );
+                               $this->logger->info( __FUNCTION__ . ": Unset 
the following session keys: $msg" );
                        }
                } else {
                        //I'm sure we could put more here...
@@ -3186,7 +3208,7 @@
                        foreach ( $soft_reset as $reset_me ) {
                                unset( $_SESSION['Donor'][$reset_me] );
                        }
-                       $this->log( __FUNCTION__ . ': Soft reset, order_id 
only', LOG_INFO );
+                       $this->logger->info( __FUNCTION__ . ': Soft reset, 
order_id only' );
                }
        }
 
@@ -3352,7 +3374,7 @@
                // fetch a salted version of the session token
                $sessionSaltedToken = $this->token_getSaltedSessionToken();
                if ( $val != $sessionSaltedToken ) {
-                       $this->log( __FUNCTION__ . ": broken session data\n", 
LOG_DEBUG );
+                       $this->logger->debug( __FUNCTION__ . ": broken session 
data\n" );
                        //and reset the token for next time.
                        $this->token_refreshAllTokenEverything();
                }
@@ -3376,7 +3398,7 @@
                        // establish the edit token to prevent csrf
                        $token = $this->token_getSaltedSessionToken();
 
-                       $this->log( 'editToken: ' . $token, LOG_DEBUG );
+                       $this->logger->debug( 'editToken: ' . $token );
 
                        // match token
                        if ( !$this->dataObj->isSomething( 'token' ) ) {
@@ -3386,8 +3408,8 @@
 
                        $match = $this->token_matchEditToken( $token_check );
                        if ( $this->dataObj->wasPosted() ) {
-                               $this->log( 'Submitted edit token: ' . 
$this->getData_Unstaged_Escaped( 'token' ), LOG_DEBUG );
-                               $this->log( 'Token match: ' . ($match ? 'true' 
: 'false' ), LOG_DEBUG );
+                               $this->logger->debug( 'Submitted edit token: ' 
. $this->getData_Unstaged_Escaped( 'token' ) );
+                               $this->logger->debug( 'Token match: ' . ($match 
? 'true' : 'false' ) );
                        }
                }
 
@@ -3466,7 +3488,7 @@
                $ref = isset( $data['referrer'] ) ? $data['referrer'] : null;
                //make it actually possible to debug this hot mess
 
-               $this->log( "Attempting to set a valid form for the 
combination: " . $this->getLogDebugJSON(), LOG_INFO );
+               $this->logger->info( "Attempting to set a valid form for the 
combination: " . $this->getLogDebugJSON() );
 
                if ( !is_null( $ffname ) && GatewayFormChooser::isValidForm( 
$ffname, $country, $currency, $payment_method, $payment_submethod, $recurring, 
$gateway ) ) {
                        return;
@@ -3475,28 +3497,28 @@
                        $this->addRequestData( array ( 'ffname' => $new_ff ) );
 
                        //and debug log a little
-                       $this->log( "Setting form to last successful 
('$new_ff')", LOG_DEBUG );
+                       $this->logger->debug( "Setting form to last successful 
('$new_ff')" );
                } else if ( GatewayFormChooser::isValidForm( $ffname . 
"-$country", $country, $currency, $payment_method, $payment_submethod, 
$recurring, $gateway ) ) {
                        //if the country-specific version exists, use that.
                        $this->addRequestData( array ( 'ffname' => $ffname . 
"-$country" ) );
 
                        //I'm only doing this for serious legacy purposes. This 
mess needs to stop itself. To help with the mess-stopping...
                        $message = "ffname '$ffname' was invalid, but the 
country-specific '$ffname-$country' works. utm_source = '$utm', referrer = 
'$ref'";
-                       $this->log( $message, LOG_WARNING );
+                       $this->logger->warning( $message );
                } else {
                        //Invalid form. Go get one that is valid, and squak in 
the error logs.
                        $new_ff = GatewayFormChooser::getOneValidForm( 
$country, $currency, $payment_method, $payment_submethod, $recurring, $gateway 
);
                        $this->addRequestData( array ( 'ffname' => $new_ff ) );
 
                        //now construct a useful error message
-                       $this->log(
+                       $this->logger->error(
                                "ffname '{$ffname}' is invalid. Assigning 
ffname '{$new_ff}'. " .
-                               "I currently am choosing for: " . 
$this->getLogDebugJSON(), LOG_ERR
+                               "I currently am choosing for: " . 
$this->getLogDebugJSON()
                        );
 
                        //Turn these off by setting the LogDebug global to 
false.
-                       $this->log( "GET: " . json_encode( $_GET ), LOG_DEBUG );
-                       $this->log( "POST: " . json_encode( $_POST ), LOG_DEBUG 
);
+                       $this->logger->debug( "GET: " . json_encode( $_GET ) );
+                       $this->logger->debug( "POST: " . json_encode( $_POST ) 
);
 
                        $dontwannalog = array (
                                'user_ip',
@@ -3522,7 +3544,7 @@
                                        unset( $data[$key] );
                                }
                        }
-                       $this->log( "Truncated DonationData: " . json_encode( 
$data ), LOG_DEBUG );
+                       $this->logger->debug( "Truncated DonationData: " . 
json_encode( $data ) );
                }
        }
 
@@ -3719,7 +3741,7 @@
                        return $value;
                } elseif ( $this->getOrderIDMeta( 'generate' ) ) {
                        //I'd dump the whole oid meta array here, but it's 
pretty much guaranteed to be empty if we're here at all.
-                       $this->log( __FUNCTION__ . ": Unable to determine what 
oid to use, in generate mode.", LOG_ERR );
+                       $this->logger->error( __FUNCTION__ . ": Unable to 
determine what oid to use, in generate mode." );
                }
 
                return null;
@@ -3828,7 +3850,7 @@
                }
 
                if ( isset( $this->payment_submethods[ $payment_submethod ] ) ) 
{
-                       $this->log( 'Getting metadata for payment submethod: ' 
. ( string ) $payment_submethod );
+                       $this->logger->info( 'Getting metadata for payment 
submethod: ' . ( string ) $payment_submethod );
 
                        // Ensure that the validation index is set.
                        if ( !isset( $this->payment_submethods[ 
$payment_submethod ]['validation'] ) ) {
diff --git a/globalcollect_gateway/globalcollect.adapter.php 
b/globalcollect_gateway/globalcollect.adapter.php
index 4247b17..5b13476 100644
--- a/globalcollect_gateway/globalcollect.adapter.php
+++ b/globalcollect_gateway/globalcollect.adapter.php
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  *
  */
+use Psr\Log\LogLevel;
 
 /**
  * GlobalCollectAdapter
@@ -1170,9 +1171,9 @@
                        $this->addResponseData( $qsResults );
                        $logmsg = 'CVV Result from querystring: ' . 
$this->getData_Unstaged_Escaped( 'cvv_result' );
                        $logmsg .= ', AVS Result from querystring: ' . 
$this->getData_Unstaged_Escaped( 'avs_result' );
-                       $this->log( $logmsg );
+                       $this->logger->info( $logmsg );
                        //add an antimessage for everything but orphans
-                       $this->log( 'Adding Antimessage' );
+                       $this->logger->info( 'Adding Antimessage' );
                        $this->doLimboStompTransaction( true );
                } else { //this is an orphan transaction.
                        $is_orphan = true;
@@ -1187,7 +1188,7 @@
                $cancelflag = false; //this will denote the thing we're trying 
to do with the donation attempt
                $problemflag = false; //this will get set to true, if we can't 
continue and need to give up and just log the hell out of it.
                $problemmessage = ''; //to be used in conjunction with the flag.
-               $problemseverity = LOG_ERR; //to be used also in conjunction 
with the flag, to route the message to the appropriate log. Urf.
+               $problemseverity = LogLevel::ERROR; //to be used also in 
conjunction with the flag, to route the message to the appropriate log. Urf.
                $original_status_code = NULL;
 
                $loopcount = $this->getGlobal( 'RetryLoopCount' );
@@ -1216,7 +1217,7 @@
                        $this->addResponseData( $xmlResults );
                        $logmsg = 'CVV Result from XML: ' . 
$this->getData_Unstaged_Escaped( 'cvv_result' );
                        $logmsg .= ', AVS Result from XML: ' . 
$this->getData_Unstaged_Escaped( 'avs_result' );
-                       $this->log( $logmsg );
+                       $this->logger->info( $logmsg );
 
                        if ( array_key_exists( 'force_cancel', $status_result ) 
&& $status_result['force_cancel'] ) {
                                $cancelflag = true; //don't retry or MasterCard 
will fine us
@@ -1268,7 +1269,7 @@
                                        case 'complete' :
                                                $problemflag = true; //nothing 
to be done.
                                                $problemmessage = 
"GET_ORDERSTATUS reports that the payment is already complete.";
-                                               $problemseverity = LOG_INFO;
+                                               $problemseverity = 
LogLevel::INFO;
                                                break 2;
                                        case 'pending-poke' :
                                                if ( $is_orphan && !$gotCVV ){
@@ -1278,13 +1279,13 @@
 
                                                //none of this should ever 
execute for a transaction that doesn't use 3d secure...
                                                if ( $txn_data['STATUSID'] === 
'200' && ( $loops < $loopcount-1 ) ){
-                                                       $this->log( "Running 
DO_FINISHPAYMENT ($loops)" );
+                                                       $this->logger->info( 
"Running DO_FINISHPAYMENT ($loops)" );
 
                                                        $dopayment_result = 
$this->do_transaction( 'DO_FINISHPAYMENT' );
                                                        $dopayment_data = 
$dopayment_result['data'];
                                                        //Check the txn status 
and result code to see if we should bother continuing
                                                        if ( 
$this->getTransactionStatus() ){
-                                                               $this->log( 
"DO_FINISHPAYMENT ($loops) returned with status ID " . 
$dopayment_data['STATUSID'] );
+                                                               
$this->logger->info( "DO_FINISHPAYMENT ($loops) returned with status ID " . 
$dopayment_data['STATUSID'] );
                                                                if ( 
$this->findCodeAction( 'GET_ORDERSTATUS', 'STATUSID', 
$dopayment_data['STATUSID'] ) === 'failed' ){
                                                                        //ack 
and die.
                                                                        
$problemflag = true; //nothing to be done.
@@ -1292,7 +1293,7 @@
                                                                        
$this->finalizeInternalStatus('failed');
                                                                }
                                                        } else {
-                                                               $this->log( 
"DO_FINISHPAYMENT ($loops) returned NOK", LOG_ERR );
+                                                               
$this->logger->error( "DO_FINISHPAYMENT ($loops) returned NOK" );
                                                        }
                                                        break;
                                                }
@@ -1361,14 +1362,14 @@
                if ( $problemflag || $cancelflag ){
                        if ( $cancelflag ){ //cancel wins
                                $problemmessage = "Cancelling payment";
-                               $problemseverity = LOG_INFO;
+                               $problemseverity = LogLevel::INFO;
                                $errors = array( '1000001' => $problemmessage );
                        } else {
                                $errors = array( '1000000' => 'Transaction 
could not be processed due to an internal error.' );
                        }
 
                        //we have probably had a communication problem that 
could mean stranded payments.
-                       $this->log( $problemmessage, $problemseverity );
+                       $this->logger->log( $problemseverity, $problemmessage );
                        //hurm. It would be swell if we had a message that told 
the user we had some kind of internal error.
                        $ret = array(
                                'status' => false,
@@ -1476,7 +1477,7 @@
                                        //I am hereby done screwing around with 
GC field constraint violations.
                                        //They vary between ***and within*** 
payment types, and their docs are a joke.
                                        if ( strpos( $message, 'DOES NOT HAVE 
LENGTH' ) !== false ) {
-                                               $this->log( $message, LOG_ERR );
+                                               $this->logger->error( $message 
);
                                        }
                                }
                        }
@@ -1509,11 +1510,11 @@
 
                                //if we have no order ID yet (or it's somehow 
wrong), retrieve it and put it in the usual place.
                                if ( array_key_exists( 'ORDERID', $data ) && ( 
$data['ORDERID'] != $this->getData_Unstaged_Escaped( 'order_id' ) ) ) {
-                                       $this->log( "inside " . 
$data['ORDERID'] );
+                                       $this->logger->info( "inside " . 
$data['ORDERID'] );
                                        $this->normalizeOrderID( 
$data['ORDERID'] );
-                                       $this->log( print_r( 
$this->getOrderIDMeta(), true ) );
+                                       $this->logger->info( print_r( 
$this->getOrderIDMeta(), true ) );
                                        $this->addRequestData( array ( 
'order_id' => $data['ORDERID'] ) );
-                                       $this->log( print_r( 
$this->getOrderIDMeta(), true ) );
+                                       $this->logger->info( print_r( 
$this->getOrderIDMeta(), true ) );
                                        $this->session_addDonorData();
                                }
 
@@ -1675,7 +1676,7 @@
                }
 
                if ( $isWarning ) {
-                       $this->log( 'Got warnings from bank validation: ' . 
print_r( $data['errors'], TRUE ), LOG_ERR );
+                       $this->logger->error( 'Got warnings from bank 
validation: ' . print_r( $data['errors'], TRUE ) );
                        $return = 'complete';
                }
 
@@ -1808,7 +1809,7 @@
                        switch ( $errCode ) {
                                case 300620:
                                // Oh no! We've already used this order # 
somewhere else! Restart!
-                                       $this->log( 'Order ID collission! 
Starting again.', LOG_ERR );
+                                       $this->logger->error( 'Order ID 
collission! Starting again.' );
                                        $retryVars[] = 'order_id';
                                        $retErrCode = $errCode;
                                        break;
@@ -1825,7 +1826,7 @@
                                        // All five these should stop us from 
retrying at all
                                        // Null out the retry vars and return 
immediately
                                        $retryVars = null;
-                                       $this->log( "Got error code $errCode, 
not retrying to avoid MasterCard fines.", LOG_INFO );
+                                       $this->logger->info( "Got error code 
$errCode, not retrying to avoid MasterCard fines." );
                                        $this->setTransactionResult( true, 
'force_cancel' );
                                        $this->setTransactionResult( array(
                                                        'internal-0003' => 
$this->getErrorMapByCodeAndTranslate( 'internal-0003' ),
@@ -1855,7 +1856,7 @@
                                        foreach ($not_errors as $regex){
                                                if ( preg_match( $regex, $raw ) 
){
                                                        //not a system error, 
but definitely the end of the payment attempt. Log it to info and leave.
-                                                       $this->log(__FUNCTION__ 
. ": $raw", LOG_INFO);
+                                                       $this->logger->info( 
__FUNCTION__ . ": $raw" );
                                                        return $errCode;
                                                }
                                        }
@@ -1873,7 +1874,7 @@
                                         * @TODO: This absolutely happens IRL. 
Attempt to handle gracefully once we figure out what that means.
                                         */
                                default:
-                                       $this->log( __FUNCTION__ . " Error 
$errCode : $errMsg", LOG_ERR );
+                                       $this->logger->error( __FUNCTION__ . " 
Error $errCode : $errMsg" );
                                        break;
                        }
                }
@@ -2027,7 +2028,7 @@
                                $this->staged_data['payment_product'] = 
$types[$payment_submethod];
                        } else {
                                if ( !empty( $payment_submethod ) ) {
-                                       $this->log( "Could not find a cc 
payment product for '$payment_submethod'", LOG_ERR );
+                                       $this->logger->error( "Could not find a 
cc payment product for '$payment_submethod'" );
                                }
                        }
 
@@ -2057,7 +2058,7 @@
 
                        // FIXME: that's one hell of a staging function.  Move 
this to a do_transaction helper.
                        if ( $enable3ds ) {
-                               $this->log( "3dSecure enabled for $currency in 
$country" );
+                               $this->logger->info( "3dSecure enabled for 
$currency in $country" );
                                
$this->transactions['INSERT_ORDERWITHPAYMENT']['values']['AUTHENTICATIONINDICATOR']
 = '1';
                        }
                } else {
@@ -2066,10 +2067,10 @@
                                if ( array_key_exists( $payment_submethod, 
$this->payment_submethods ) && isset( 
$this->payment_submethods[$payment_submethod]['paymentproductid'] ) ) {
                                        $this->staged_data['payment_product'] = 
$this->payment_submethods[$payment_submethod]['paymentproductid'];
                                } else {
-                                       $this->log( "Could not find a payment 
product for '$payment_submethod' in payment_submethods array", LOG_ERR );
+                                       $this->logger->error( "Could not find a 
payment product for '$payment_submethod' in payment_submethods array" );
                                }
                        } else {
-                               $this->log( "payment_submethod found to be 
empty. Probably okay though.", LOG_DEBUG );
+                               $this->logger->debug( "payment_submethod found 
to be empty. Probably okay though." );
                        }
                }
        }
diff --git a/globalcollect_gateway/scripts/orphan_adapter.php 
b/globalcollect_gateway/scripts/orphan_adapter.php
index 0e0806b..ff2bc1f 100644
--- a/globalcollect_gateway/scripts/orphan_adapter.php
+++ b/globalcollect_gateway/scripts/orphan_adapter.php
@@ -5,6 +5,10 @@
        //so far: order_id and the utm data we pull from contribution tracking. 
        protected $hard_data = array ( );
 
+       public static function getLogIdentifier() {
+               return 'orphans:' . self::getIdentifier() . "_gateway_trxn";
+       }
+
        public function __construct() {
                $this->batch = true; //always batch if we're using this object.
                parent::__construct( $options = array ( ) );
@@ -99,31 +103,6 @@
                }
        }
 
-       /**
-        * Unfortunate, but we have to overload this here, or change the way we
-        * build that identifier.
-        * @param string $msg
-        * @param type $log_level
-        * @param type $nothing
-        * @return type
-        */
-       public function log( $msg, $log_level = LOG_INFO, $nothing = null ) {
-               $identifier = 'orphans:' . self::getIdentifier() . 
"_gateway_trxn";
-
-               $msg = $this->getLogMessagePrefix() . $msg;
-
-               // if we're not using the syslog facility, use wfDebugLog
-               if ( !self::getGlobal( 'UseSyslog' ) ) {
-                       WmfFramework::debugLog( $identifier, $msg );
-                       return;
-               }
-
-               // otherwise, use syslogging
-               openlog( $identifier, LOG_ODELAY, LOG_SYSLOG );
-               syslog( $log_level, $msg );
-               closelog();
-       }
-
        public function getUTMInfoFromDB() {
                $db = 
ContributionTrackingProcessor::contributionTrackingConnection();
 
@@ -156,14 +135,14 @@
                                foreach ( $data as $key => $val ) {
                                        $msg .= "$key = $val ";
                                }
-                               $this->log( "$ctid: Found UTM Data. $msg" );
+                               $this->logger->info( "$ctid: Found UTM Data. 
$msg" );
                                echo "$msg\n";
                                return $data;
                        }
                }
 
                //if we got here, we can't find anything else...
-               $this->log( "$ctid: FAILED to find UTM Source value. Using 
default.", LOG_ERR );
+               $this->logger->error( "$ctid: FAILED to find UTM Source value. 
Using default." );
                return $data;
        }
 
@@ -214,7 +193,7 @@
                try {
                        WmfFramework::runHooks( $hook, array( $transaction ) );
                } catch ( Exception $e ) {
-                       $this->log( "STOMP ERROR. Could not add message. " . 
$e->getMessage(), LOG_CRIT );
+                       $this->logger->critical( "STOMP ERROR. Could not add 
message. " . $e->getMessage() );
                }
        }
 
diff --git a/globalcollect_gateway/scripts/orphans.php 
b/globalcollect_gateway/scripts/orphans.php
index c3bb793..3e53492 100644
--- a/globalcollect_gateway/scripts/orphans.php
+++ b/globalcollect_gateway/scripts/orphans.php
@@ -53,7 +53,8 @@
                        'wheeee' => 'yes'
                );
                $this->adapter = new 
GlobalCollectOrphanAdapter(array('external_data' => $data));
-               
+               $this->logger = DonationLoggerFactory::getLogger( 
$this->adapter );
+
                //Now, actually do the processing. 
                if ( method_exists( $this, $func ) ) {
                        $this->{$func}();
@@ -88,7 +89,7 @@
                                sleep(2); //two seconds. 
                        }
                }
-               $this->adapter->log( 'Removed ' . $this->removed_message_count 
. ' messages and antimessages.' );
+               $this->logger->info( 'Removed ' . $this->removed_message_count 
. ' messages and antimessages.' );
                
                if ( $this->keepGoing() ){
                        //Pull a batch of CC orphans, keeping in mind that 
Things May Have Happened in the small slice of time since we handled the 
antimessages. 
@@ -149,7 +150,7 @@
                        }
                }
                $final .= "\n Approximately " . $this->getProcessElapsed() . " 
seconds to execute.\n";
-               $this->adapter->log($final);
+               $this->logger->info( $final );
                echo $final;
        }
        
@@ -217,7 +218,7 @@
                        $antimessages = stompFetchMessages( 'cc-limbo', 
$selector, 1000 );
                }
                $this->addStompCorrelationIDToAckBucket( false, true ); //this 
just acks everything that's waiting for it.
-               $this->adapter->log("Found $count antimessages.");
+               $this->logger->info( "Found $count antimessages." );
                return $count;
        }
        
@@ -355,10 +356,10 @@
                $this->adapter->loadDataAndReInit( $data, 
$query_contribution_tracking );
                $results = $this->adapter->do_transaction( 'Confirm_CreditCard' 
);
                if ($results['status']){
-                       $this->adapter->log( $data['contribution_tracking_id'] 
. ": FINAL: " . $results['action'] );
+                       $this->logger->info( $data['contribution_tracking_id'] 
. ": FINAL: " . $results['action'] );
                        $rectified = true;
                } else {
-                       $this->adapter->log( $data['contribution_tracking_id'] 
. ": ERROR: " . $results['message'] );
+                       $this->logger->info( $data['contribution_tracking_id'] 
. ": ERROR: " . $results['message'] );
                        if ( strpos( $results['message'], "GET_ORDERSTATUS 
reports that the payment is already complete." ) === 0  ){
                                $rectified = true;
                        }
diff --git a/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php 
b/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
index cca04de..3f2e0be 100644
--- a/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
+++ b/tests/Adapter/GlobalCollect/GlobalCollectOrphanAdapterTest.php
@@ -16,6 +16,7 @@
  * GNU General Public License for more details.
  *
  */
+use Psr\Log\LogLevel;
 
 /**
  *
@@ -51,7 +52,7 @@
 
                $this->assertInstanceOf( $class, $gateway );
 
-               $this->verifyNoLogErrors( $gateway );
+               $this->verifyNoLogErrors();
        }
 
 
@@ -73,7 +74,7 @@
                $gateway->loadDataAndReInit( $data, $useDB = false );
                $this->assertEquals( $gateway->getData_Unstaged_Escaped( 
'order_id' ), '444444', 'loadDataAndReInit failed to stick OrderID' );
 
-               $this->verifyNoLogErrors( $gateway );
+               $this->verifyNoLogErrors();
        }
 
        public function testBatchOrderID_no_generate() {
@@ -94,7 +95,7 @@
                $gateway->loadDataAndReInit( $data, $useDB = false );
                $this->assertEquals( $gateway->getData_Unstaged_Escaped( 
'order_id' ), '777777', 'loadDataAndReInit failed to stick OrderID on second 
batch item' );
 
-               $this->verifyNoLogErrors( $gateway );
+               $this->verifyNoLogErrors();
        }
 
        public function testGCFormLoad() {
@@ -142,7 +143,7 @@
                $this->assertEquals( false, $result['status'], "Error code 
$code should mean status of do_transaction is false" );
                $this->assertTrue( array_key_exists( 'errors', $result ), 
'Orphan adapter needs to see the errors to consider it rectified' );
                $this->assertTrue( array_key_exists('1000001', 
$result['errors'] ), 'Orphan adapter needs error 1000001 to consider it 
rectified' );
-               $logline = $this->getGatewayLogMatches( $gateway, LOG_INFO, 
"/Got error code $code, not retrying to avoid MasterCard fines./" );
-               $this->assertType( 'string', $logline, "GC Error $code is not 
generating the expected payments log error" );
+               $loglines = $this->getLogMatches( LogLevel::INFO, "/Got error 
code $code, not retrying to avoid MasterCard fines./" );
+               $this->assertNotEmpty( $loglines, "GC Error $code is not 
generating the expected payments log error" );
        }
 }
diff --git a/tests/Adapter/GlobalCollect/GlobalCollectTest.php 
b/tests/Adapter/GlobalCollect/GlobalCollectTest.php
index 709162c..faf8a88 100644
--- a/tests/Adapter/GlobalCollect/GlobalCollectTest.php
+++ b/tests/Adapter/GlobalCollect/GlobalCollectTest.php
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  *
  */
+use Psr\Log\LogLevel;
 
 /**
  *
@@ -315,22 +316,25 @@
                $gateway = $this->getFreshGatewayObject( $init );
                $gateway->setDummyGatewayResponseCode( '430285' );
                $gateway->do_transaction( 'GET_ORDERSTATUS' );
-               $this->verifyNoLogErrors( $gateway );
+               $this->verifyNoLogErrors();
 
                //Now test one we want to throw a payments error
                $gateway = $this->getFreshGatewayObject( $init );
                $gateway->setDummyGatewayResponseCode( '21000050' );
                $gateway->do_transaction( 'GET_ORDERSTATUS' );
-               $logline = $this->getGatewayLogMatches( $gateway, LOG_ERR, 
'/Investigation required!/' );
-               $this->assertType( 'string', $logline, 'GC Error 21000050 is 
not generating the expected payments log error' );
+               $loglines = $this->getLogMatches( LogLevel::ERROR, 
'/Investigation required!/' );
+               $this->assertNotEmpty( $loglines, 'GC Error 21000050 is not 
generating the expected payments log error' );
+
+               //Reset logs
+               $this->testLogger->messages = array();
 
                //Most irritating version of 20001000 - They failed to enter an 
expiration date on GC's form. This should log some specific info, but not an 
error.
                $gateway = $this->getFreshGatewayObject( $init );
                $gateway->setDummyGatewayResponseCode( '20001000-expiry' );
                $gateway->do_transaction( 'GET_ORDERSTATUS' );
-               $this->verifyNoLogErrors( $gateway );
-               $logline = $this->getGatewayLogMatches( $gateway, LOG_INFO, 
'/processResponse:.*EXPIRYDATE/' );
-               $this->assertType( 'string', $logline, 'GC Error 
20001000-expiry is not generating the expected payments log line' );
+               $this->verifyNoLogErrors();
+               $loglines = $this->getLogMatches( LogLevel::INFO, 
'/processResponse:.*EXPIRYDATE/' );
+               $this->assertNotEmpty( $loglines, 'GC Error 20001000-expiry is 
not generating the expected payments log line' );
        }
 
        /**
@@ -429,8 +433,8 @@
                $start_id = $gateway->_getData_Staged( 'order_id' );
                $gateway->do_transaction( 'Confirm_CreditCard' );
                $finish_id = $gateway->_getData_Staged( 'order_id' );
-               $logline = $this->getGatewayLogMatches( $gateway, LOG_INFO, 
'/Repeating transaction on request for vars:/' );
-               $this->assertEmpty( $logline, "Log says we are going to repeat 
the transaction for code $code, but that is not true" );
+               $loglines = $this->getLogMatches( LogLevel::INFO, '/Repeating 
transaction on request for vars:/' );
+               $this->assertEmpty( $loglines, "Log says we are going to repeat 
the transaction for code $code, but that is not true" );
                $this->assertEquals( $start_id, $finish_id, "Needlessly 
regenerated order id for code $code ");
        }
 }
diff --git a/tests/Adapter/WorldPay/WorldPayTest.php 
b/tests/Adapter/WorldPay/WorldPayTest.php
index cb91dd8..1c90d87 100644
--- a/tests/Adapter/WorldPay/WorldPayTest.php
+++ b/tests/Adapter/WorldPay/WorldPayTest.php
@@ -78,11 +78,11 @@
                $this->assertInstanceOf( 'TestingWorldPayAdapter', $gateway );
                $gateway->do_transaction( 'AuthorizePaymentForFraud' );
 
-               $logline = $this->getGatewayLogMatches( $gateway, LOG_INFO, 
'/Request XML/' );
+               $loglines = $this->getLogMatches( LogLevel::INFO, '/Request 
XML/' );
 
-               $this->assertType( 'string', $logline, "We did not receive 
exactly one logline back that contains request XML" );
-               $this->assertEquals( '1', preg_match( '/Cleaned/', $logline ), 
'The logline did not come back marked as "Cleaned".' );
-               $this->assertEquals( '0', preg_match( '/CNV/', $logline ), 'The 
"Cleaned" logline contained CVN data!' );
+               $this->assertEquals( 1, count( $loglines ), "We did not receive 
exactly one logline back that contains request XML" );
+               $this->assertEquals( 1, preg_match( '/Cleaned/', $loglines[0] 
), 'The logline did not come back marked as "Cleaned".' );
+               $this->assertEquals( 0, preg_match( '/CNV/', $loglines[0] ), 
'The "Cleaned" logline contained CVN data!' );
        }
 
        function testWorldPayFormLoad() {
diff --git a/tests/DonationInterfaceTestCase.php 
b/tests/DonationInterfaceTestCase.php
index 85d77b9..1618603 100644
--- a/tests/DonationInterfaceTestCase.php
+++ b/tests/DonationInterfaceTestCase.php
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  *
  */
+use Psr\Log\LogLevel;
 
 /**
  * @group              Fundraising
@@ -458,7 +459,7 @@
                // file_put_contents( '/tmp/xmlout.txt', $form_html );
 
                if ( $fail_on_log_errors ) {
-                       $this->verifyNoLogErrors( $formpage->adapter );
+                       $this->verifyNoLogErrors();
                }
 
                $dom_thingy = new DomDocument();
@@ -550,20 +551,19 @@
                $this->assertEquals( $check, $value, "Expected $label to be 
$check, found $value instead.");
        }
        /**
-        * Asserts that $gateway has no log entries of LOG_ERR or worse.
-        * @param object $gateway The gateway to check
+        * Asserts that there are no log entries of LOG_ERR or worse.
         */
-       function verifyNoLogErrors( $gateway ) {
-               $log = $gateway->testlog;
+       function verifyNoLogErrors( ) {
+               $log = $this->testLogger->messages;
 
-               $this->assertTrue( is_array( $log ), "Missing the adapter 
testlog" );
+               $this->assertTrue( is_array( $log ), "Missing the test log" );
 
                //for our purposes, an "error" is LOG_ERR or less.
                $checklogs = array (
-                       LOG_ERR => "Oops: We've got LOG_ERRors.",
-                       LOG_CRIT => "Critical errors!",
-                       LOG_ALERT => "Log Alerts!",
-                       LOG_EMERG => "Logs says the servers are actually on 
fire.",
+                       LogLevel::ERROR => "Oops: We've got LOG_ERRors.",
+                       LogLevel::CRITICAL => "Critical errors!",
+                       LogLevel::ALERT => "Log Alerts!",
+                       LogLevel::EMERGENCY => "Logs says the servers are 
actually on fire.",
                );
 
                $message = false;
@@ -578,35 +578,6 @@
 
        /**
         * Finds a relevant line/lines in a gateway's log array
-        * @param test adapter $gateway The gateway that should have the log 
line you're looking for.
-        * @param integer $log_level A standard level that the line should... 
get logged at.
-        * @param string $match A regex to match against the log lines.
-        * @return mixed The full log line that matches the $match, an array if 
there were multiples, or false if none were found.
-        */
-       public function getGatewayLogMatches( $gateway, $log_level, $match ) {
-               $log = $gateway->testlog;
-               if ( !array_key_exists( $log_level, $log ) ) {
-                       return false;
-               }
-
-               $return = array ( );
-               foreach ( $log[$log_level] as $line ) {
-                       if ( preg_match( $match, $line ) ) {
-                               $return[] = $line;
-                       }
-               }
-
-               if ( empty( $return ) ) {
-                       return false;
-               }
-               if ( sizeof( $return ) === 1 ) {
-                       return $return[0];
-               }
-               return $return;
-       }
-
-       /**
-        * Version of @see getGatewayLogMatches, but checking the mock PSR-3 
logger.
         * @param string $log_level One of the constants in \Psr\Log\LogLevel
         * @param string $match A regex to match against the log lines.
         * @return array All log lines that match $match.
diff --git a/tests/IntegrationTest.php b/tests/IntegrationTest.php
index b7f492b..0473de8 100644
--- a/tests/IntegrationTest.php
+++ b/tests/IntegrationTest.php
@@ -15,6 +15,7 @@
  * GNU General Public License for more details.
  *
  */
+use Psr\Log\LogLevel;
 
 /**
  * @group Fundraising
@@ -58,8 +59,8 @@
                $this->assertEquals( 'cc-vmad', $ffname, "GC did not load the 
expected form." );
 
                $errors = '';
-               if ( array_key_exists( LOG_ERR, $gateway->testlog ) ) {
-                       foreach ( $gateway->testlog[LOG_ERR] as $msg ) {
+               if ( array_key_exists( LogLevel::ERROR, 
$this->testLogger->messages ) ) {
+                       foreach ( $this->testLogger->messages[LogLevel::ERROR] 
as $msg ) {
                                $errors += "$msg\n";
                        }
                }
@@ -67,5 +68,3 @@
        }
 
 }
-
-
diff --git a/worldpay_gateway/worldpay.adapter.php 
b/worldpay_gateway/worldpay.adapter.php
index 5c36b35..db315d0 100644
--- a/worldpay_gateway/worldpay.adapter.php
+++ b/worldpay_gateway/worldpay.adapter.php
@@ -1011,7 +1011,7 @@
                                                $currency === $storeCurrency
                                        ) {
                                                list( $merchantId, $storeId ) = 
$info;
-                                               $this->log( "Using MID: 
{$merchantId}, SID: {$storeId} for " .
+                                               $this->logger->info( "Using 
MID: {$merchantId}, SID: {$storeId} for " .
                                                        "submethod: 
{$submethod}, country: {$country}, currency: {$currency}."
                                                );
                                                break;
@@ -1139,7 +1139,7 @@
                // Obtain all the form data from tokenization server
                $result = $this->do_transaction( 'QueryTokenData' );
                if ( !$this->getTransactionStatus() ) {
-                       $this->log( 'Failed transaction because QueryTokenData 
failed', LOG_ERR );
+                       $this->logger->error( 'Failed transaction because 
QueryTokenData failed' );
                        $this->finalizeInternalStatus( 'failed' );
                        return $result;
                }
@@ -1149,14 +1149,14 @@
                if ( $this->getGlobal( 'NoFraudIntegrationTest' ) !== true ) {
                        $result = $this->do_transaction( 
'AuthorizePaymentForFraud' );
                        if ( !$this->getTransactionStatus() ) {
-                               $this->log( 'Failed transaction because 
AuthorizePaymentForFraud failed' );
+                               $this->logger->info( 'Failed transaction 
because AuthorizePaymentForFraud failed' );
                                $this->finalizeInternalStatus( 'failed' );
                                return $result;
                        }
                        $code = $result[ 'data' ][ 'MessageCode' ];
                        $result_status = $this->findCodeAction( 
'AuthorizePaymentForFraud', 'MessageCode', $code );
                        if ( $result_status ) {
-                               $this->log(
+                               $this->logger->info(
                                        "Finalizing transaction at 
AuthorizePaymentForFraud to {$result_status}. Code: {$code}"
                                );
                                //NOOOOO.
@@ -1171,22 +1171,21 @@
                // We've successfully passed fraud checks; authorize and 
deposit the payment
                $result = $this->do_transaction( 'AuthorizeAndDepositPayment' );
                if ( !$this->getTransactionStatus() ) {
-                       $this->log( 'Failed transaction because 
AuthorizeAndDepositPayment failed' );
+                       $this->logger->info( 'Failed transaction because 
AuthorizeAndDepositPayment failed' );
                        $this->finalizeInternalStatus( 'failed' );
                        return $result;
                }
                $code = $result[ 'data' ][ 'MessageCode' ];
                $result_status = $this->findCodeAction( 
'AuthorizeAndDepositPayment', 'MessageCode', $code );
                if ( $result_status ) {
-                       $this->log(
+                       $this->logger->info(
                                "Finalizing transaction at 
AuthorizeAndDepositPayment to {$result_status}. Code: {$code}"
                        );
                        $this->finalizeInternalStatus( $result_status );
                } else {
-                       $this->log(
+                       $this->logger->error(
                                'Finalizing transaction at 
AuthorizeAndDepositPayment to failed because MessageCode (' .
-                               $code . ') was unknown.',
-                               LOG_ERR
+                               $code . ') was unknown.'
                        );
                        $this->finalizeInternalStatus( 'failed' );
                }

-- 
To view, visit https://gerrit.wikimedia.org/r/193272
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I0cc0115455d0e456a19390a00774e72864c6fde8
Gerrit-PatchSet: 5
Gerrit-Project: mediawiki/extensions/DonationInterface
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Katie Horn <[email protected]>
Gerrit-Reviewer: Ssmith <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to