QUAL Replace var_export() with json_encode() in dol_syslog() calls (#37138)
var_export() produces multiline output that breaks log aggregators (Loki, Splunk, Elasticsearch, Graylog) as each line becomes a separate log entry. json_encode() produces single-line structured output that works correctly with all log aggregation tools. This pattern is already used elsewhere in Dolibarr (accountancy, install modules). Files changed: - core/class/commoninvoice.class.php (payment intent logging) - core/class/commonobject.class.php (payment terms logging) - core/modules/mailings/advthirdparties.modules.php (mailing targets) - core/modules/oauth/google_oauthcallback.php (userinfo logging) - core/modules/oauth/generic_oauthcallback.php (userinfo logging) - public/payment/newpayment.php (GET/POST debug logging) - public/payment/paymentok.php (payment tag logging) - public/stripe/ipn.php (Stripe event data logging) - paypal/lib/paypal.lib.php (PayPal response logging) - api/index.php (API debug logging) - stripe/class/stripe.class.php (payment/setup intent logging) Co-authored-by: f-hoedl <hoefla14@htl-kaindorf.ac.at> Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
parent
9ac93e1e98
commit
92562150ec
6 changed files with 27 additions and 27 deletions
|
|
@ -205,7 +205,7 @@ if (getDolGlobalString('MAIN_API_DEBUG')) {
|
|||
// 'route' => $api->r->apiMethodInfo->className.'::'.$api->r->apiMethodInfo->methodName,
|
||||
// 'version' => $api->r->getRequestedApiVersion(),
|
||||
// 'data' => $api->r->getRequestData(),
|
||||
//dol_syslog("Debug API input ".formatLogObject($r), LOG_DEBUG, 0, '_api');
|
||||
//dol_syslog("Debug API input ".formatLogOb
|
||||
dol_syslog("Debug API url ".formatLogObject($r->url), LOG_DEBUG, 0, '_api');
|
||||
dol_syslog("Debug API input ".formatLogObject($r->getRequestData()), LOG_DEBUG, 0, '_api');
|
||||
//}
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ if (!GETPOST('code') && !GETPOST('error')) {
|
|||
if (!empty($jwt[1])) {
|
||||
$userinfo = json_decode(base64_decode($jwt[1]), true);
|
||||
|
||||
dol_syslog("userinfo=".var_export($userinfo, true));
|
||||
dol_syslog("userinfo=".formatLogObject($userinfo));
|
||||
|
||||
$useremail = $userinfo['email'];
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ function print_paypal_redirect($paymentAmount, $currencyCodeType, $paymentType,
|
|||
$desc
|
||||
);
|
||||
|
||||
dol_syslog("print_paypal_redirect resArray=".var_export($resArray, true), LOG_DEBUG);
|
||||
dol_syslog("print_paypal_redirect resArray=".formatLogObject($resArray), LOG_DEBUG);
|
||||
|
||||
$ack = strtoupper($resArray["ACK"]);
|
||||
if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ if (isModEnabled('paypal') && $paymentmethod === 'paypal') { // We call this pag
|
|||
// Nothing to do
|
||||
dol_syslog("Call to GetExpressCheckoutDetails return ".$ack, LOG_DEBUG, 0, '_payment');
|
||||
} else {
|
||||
dol_syslog("Call to GetExpressCheckoutDetails return error: ".json_encode($resArray), LOG_WARNING, 0, '_payment');
|
||||
dol_syslog("Call to GetExpressCheckoutDetails return error: ".formatLogObject($resArray), LOG_WARNING, 0, '_payment');
|
||||
}
|
||||
|
||||
dol_syslog("We call DoExpressCheckoutPayment token=".$onlinetoken." paymentType=".$paymentType." currencyCodeType=".$currencyCodeType." payerID=".$payerID." ipaddress=".$ipaddress." FinalPaymentAmt=".$FinalPaymentAmt." fulltag=".$fulltag, LOG_DEBUG, 0, '_payment');
|
||||
|
|
@ -343,7 +343,7 @@ if (isModEnabled('paypal') && $paymentmethod === 'paypal') { // We call this pag
|
|||
|
||||
$ispaymentok = true;
|
||||
} else {
|
||||
dol_syslog("Call to DoExpressCheckoutPayment return error: ".json_encode($resArray2), LOG_WARNING, 0, '_payment');
|
||||
dol_syslog("Call to DoExpressCheckoutPayment return error: ".formatLogObject($resArray2), LOG_WARNING, 0, '_payment');
|
||||
|
||||
//Display a user friendly Error on the page using any of the following error information returned by PayPal
|
||||
$ErrorCode = urldecode($resArray2["L_ERRORCODE0"]);
|
||||
|
|
|
|||
|
|
@ -193,8 +193,8 @@ sleep(2);
|
|||
|
||||
if ($event->type == 'payout.created' && getDolGlobalString('STRIPE_AUTO_RECORD_PAYOUT')) {
|
||||
// When a payout is created by Stripe to transfer money to your account
|
||||
dol_syslog("object = ".var_export($event->data, true));
|
||||
dol_syslog("object = ".var_export($event->data, true), LOG_DEBUG, 0, '_payment');
|
||||
dol_syslog("object = ".formatLogObject($event->data));
|
||||
dol_syslog("object = ".formatLogObject($event->data), LOG_DEBUG, 0, '_payment');
|
||||
|
||||
$error = 0;
|
||||
|
||||
|
|
@ -239,8 +239,8 @@ if ($event->type == 'payout.created' && getDolGlobalString('STRIPE_AUTO_RECORD_P
|
|||
}
|
||||
} elseif ($event->type == 'payout.paid' && getDolGlobalString('STRIPE_AUTO_RECORD_PAYOUT')) {
|
||||
// When a payout to transfer money to your account is completely done
|
||||
dol_syslog("object = ".var_export($event->data, true));
|
||||
dol_syslog("object = ".var_export($event->data, true), LOG_DEBUG, 0, '_payment');
|
||||
dol_syslog("object = ".formatLogObject($event->data));
|
||||
dol_syslog("object = ".formatLogObject($event->data), LOG_DEBUG, 0, '_payment');
|
||||
|
||||
$error = 0;
|
||||
$result = dolibarr_set_const($db, $service."_NEXTPAYOUT", 0, 'chaine', 0, '', $conf->entity);
|
||||
|
|
@ -361,8 +361,8 @@ if ($event->type == 'payout.created' && getDolGlobalString('STRIPE_AUTO_RECORD_P
|
|||
$db->commit();
|
||||
} elseif ($event->type == 'payment_intent.succeeded') {
|
||||
// Called when making payment with PaymentIntent method.
|
||||
dol_syslog("object = ".var_export($event->data, true));
|
||||
dol_syslog("object = ".var_export($event->data, true), LOG_DEBUG, 0, '_payment');
|
||||
dol_syslog("object = ".formatLogObject($event->data));
|
||||
dol_syslog("object = ".formatLogObject($event->data), LOG_DEBUG, 0, '_payment');
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT . '/compta/paiement/class/paiement.class.php';
|
||||
global $stripearrayofkeysbyenv;
|
||||
|
|
@ -448,8 +448,8 @@ if ($event->type == 'payout.created' && getDolGlobalString('STRIPE_AUTO_RECORD_P
|
|||
|
||||
$stripeacc = $stripearrayofkeysbyenv[$servicestatus]['secret_key'];
|
||||
|
||||
dol_syslog("Get the Stripe payment object for the payment method id = ".json_encode($paymentmethodstripeid));
|
||||
dol_syslog("Get the Stripe payment object for the payment method id = ".json_encode($paymentmethodstripeid), LOG_DEBUG, 0, '_payment');
|
||||
dol_syslog("Get the Stripe payment object for the payment method id = ".formatLogObject($paymentmethodstripeid));
|
||||
dol_syslog("Get the Stripe payment object for the payment method id = ".formatLogObject($paymentmethodstripeid), LOG_DEBUG, 0, '_payment');
|
||||
|
||||
$s = new \Stripe\StripeClient($stripeacc);
|
||||
|
||||
|
|
@ -872,8 +872,8 @@ if ($event->type == 'payout.created' && getDolGlobalString('STRIPE_AUTO_RECORD_P
|
|||
} elseif ($event->type == 'checkout.session.completed') { // Called when making payment with new Checkout method (getDolGlobalString('STRIPE_USE_NEW_CHECKOUT') is on).
|
||||
// TODO: create fees
|
||||
} elseif ($event->type == 'payment_method.attached') {
|
||||
dol_syslog("object = ".var_export($event->data, true));
|
||||
dol_syslog("object = ".var_export($event->data, true), LOG_DEBUG, 0, '_payment');
|
||||
dol_syslog("object = ".formatLogObject($event->data));
|
||||
dol_syslog("object = ".formatLogObject($event->data), LOG_DEBUG, 0, '_payment');
|
||||
|
||||
// When we link a payment method with a customer on Stripe side
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/companypaymentmode.class.php';
|
||||
|
|
@ -924,8 +924,8 @@ if ($event->type == 'payout.created' && getDolGlobalString('STRIPE_AUTO_RECORD_P
|
|||
}
|
||||
}
|
||||
} elseif ($event->type == 'payment_method.updated') {
|
||||
dol_syslog("object = ".var_export($event->data, true));
|
||||
dol_syslog("object = ".var_export($event->data, true), LOG_DEBUG, 0, '_payment');
|
||||
dol_syslog("object = ".formatLogObject($event->data));
|
||||
dol_syslog("object = ".formatLogObject($event->data), LOG_DEBUG, 0, '_payment');
|
||||
|
||||
// When we update a payment method on Stripe side
|
||||
require_once DOL_DOCUMENT_ROOT.'/societe/class/companypaymentmode.class.php';
|
||||
|
|
@ -978,12 +978,12 @@ if ($event->type == 'payout.created' && getDolGlobalString('STRIPE_AUTO_RECORD_P
|
|||
// Deprecated.
|
||||
} elseif ($event->type == 'charge.dispute.closed') {
|
||||
// When a dispute to cancel a SEPA payment is finished
|
||||
dol_syslog("object = ".var_export($event->data, true));
|
||||
dol_syslog("object = ".var_export($event->data, true), LOG_DEBUG, 0, '_payment');
|
||||
dol_syslog("object = ".formatLogObject($event->data));
|
||||
dol_syslog("object = ".formatLogObject($event->data), LOG_DEBUG, 0, '_payment');
|
||||
} elseif ($event->type == 'charge.dispute.funds_withdrawn') {
|
||||
// When a dispute/withdraw to cancel a payment (card or SEPA) is done
|
||||
dol_syslog("object = ".var_export($event->data, true));
|
||||
dol_syslog("object = ".var_export($event->data, true), LOG_DEBUG, 0, '_payment');
|
||||
dol_syslog("object = ".formatLogObject($event->data));
|
||||
dol_syslog("object = ".formatLogObject($event->data), LOG_DEBUG, 0, '_payment');
|
||||
|
||||
global $stripearrayofkeysbyenv;
|
||||
$error = 0;
|
||||
|
|
|
|||
|
|
@ -588,7 +588,7 @@ class Stripe extends CommonObject
|
|||
}
|
||||
|
||||
dol_syslog(get_class($this)."::getPaymentIntent ".$stripearrayofkeysbyenv[$servicestatus]['publishable_key'], LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::getPaymentIntent dataforintent to create paymentintent = ".var_export($dataforintent, true));
|
||||
dol_syslog(get_class($this)."::getPaymentIntent dataforintent to create paymentintent = ".formatLogObject($dataforintent));
|
||||
|
||||
$paymentintent = \Stripe\PaymentIntent::create($dataforintent, $arrayofoptions);
|
||||
|
||||
|
|
@ -721,7 +721,7 @@ class Stripe extends CommonObject
|
|||
|
||||
$noidempotency_key = 1;
|
||||
|
||||
dol_syslog("getSetupIntent description=".$description.' confirmnow='.json_encode($confirmnow), LOG_INFO, 1);
|
||||
dol_syslog("getSetupIntent description=".$description.' confirmnow='.formatLogObject($confirmnow), LOG_INFO, 1);
|
||||
|
||||
$error = 0;
|
||||
|
||||
|
|
@ -797,7 +797,7 @@ class Stripe extends CommonObject
|
|||
\Stripe\Stripe::setApiKey($stripearrayofkeysbyenv[$servicestatus]['secret_key']);
|
||||
|
||||
dol_syslog(get_class($this)."::getSetupIntent ".$stripearrayofkeysbyenv[$servicestatus]['publishable_key'], LOG_DEBUG);
|
||||
dol_syslog(get_class($this)."::getSetupIntent dataforintent to create setupintent = ".var_export($dataforintent, true));
|
||||
dol_syslog(get_class($this)."::getSetupIntent dataforintent to create setupintent = ".formatLogObject($dataforintent));
|
||||
|
||||
// Note: If all data for payment intent are same than a previous one, even if we use 'create', Stripe will return ID of the old existing payment intent.
|
||||
if (empty($key)) { // If the Stripe connect account not set, we use common API usage
|
||||
|
|
@ -956,7 +956,7 @@ class Stripe extends CommonObject
|
|||
try {
|
||||
if (empty($stripeacc)) { // If the Stripe connect account not set, we use common API usage
|
||||
if (!getDolGlobalString('STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) {
|
||||
dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard));
|
||||
dol_syslog("Try to create card with dataforcard = ".formatLogObject($dataforcard));
|
||||
$card = $cu->sources->create($dataforcard);
|
||||
if (!$card) {
|
||||
$this->error = 'Creation of card on Stripe has failed';
|
||||
|
|
@ -977,7 +977,7 @@ class Stripe extends CommonObject
|
|||
}
|
||||
} else {
|
||||
if (!getDolGlobalString('STRIPE_USE_INTENT_WITH_AUTOMATIC_CONFIRMATION')) {
|
||||
dol_syslog("Try to create card with dataforcard = ".json_encode($dataforcard));
|
||||
dol_syslog("Try to create card with dataforcard = ".formatLogObject($dataforcard));
|
||||
$card = $cu->sources->create($dataforcard, array("stripe_account" => $stripeacc));
|
||||
if (!$card) {
|
||||
$this->error = 'Creation of card on Stripe has failed';
|
||||
|
|
@ -1131,7 +1131,7 @@ class Stripe extends CommonObject
|
|||
global $stripearrayofkeysbyenv;
|
||||
$stripeacc = $stripearrayofkeysbyenv[$servicestatus]['secret_key'];
|
||||
|
||||
dol_syslog("Try to create sepa_debit with data = ".json_encode($dataforcard));
|
||||
dol_syslog("Try to create sepa_debit with data = ".formatLogObject($dataforcard));
|
||||
|
||||
$s = new \Stripe\StripeClient($stripeacc);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue