Comments (8)
The logger object you provide on Client instantiation should be an instance of Psr\Log\LoggerInterface
. You can provide a Monolog logger or any other PSR-compatible log object which can be set up to log to a file or a DB or anything you like.
If you do that, you'll find all request and response XML's in the logfile.
You shouldn't be overriding the log function, you should just provide a PSR compatible logging object to log to the location of your choice.
I will make filling the responseXml a configurable parameter, but I can't turn it off by default until I release a 2.0 version - since I'm following semantic versioning.
from amadeus-ws-client.
Here's a sample:
First step: install Monolog as a dependency.
Setup a logger to log to a file on your machine:
<?php
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
// create a log channel
$log = new Logger('name');
$log->pushHandler(new StreamHandler('/var/www/myapp/logs/requestresponse.log', Logger::INFO));
Now use the $log
object you created instead of the NullLogger
as shown in the client instantiation example: https://github.com/amabnl/amadeus-ws-client/blob/master/docs/about-get-started.rst#set-up-a-test-client
Execute some messages through the client, and you'll find the entire request & response messages in /var/www/myapp/logs/requestresponse.log
.
from amadeus-ws-client.
If you provide a logger to the client, it will log all requests & responses.
Do you mean that having responseXml in the result object should be optional? What's your reasoning for that?
from amadeus-ws-client.
Hm, yes -- adding things to the default log()
@ NullLogger.php
or creating an own logger and adding stuff to it seems to interrupt everything and not return the raw xml messages though? Expected, from me, is that one has the ability to simply put stuff into logs without interrupting the normal flow.
ie:
public function log($level, $message, array $context = array())
{
print_r($message);
print_r($level);
print_r($context);
}
What i want is basically to turn on logging and then log every XML req/response as files, in a db or whatever.
The reasoning for not including the RAW XML in the response (making it object + raw xml) is that some results are 0.7-1 MB in pure XML. Hardly matters for tiny responses/requests, but try 250 results using MasterPricer and then have 100 of such requests in 1 second. :)
from amadeus-ws-client.
-
Hm -- okay. It seems to be beyond my understanding unfortunately. Will try to figure it out anyway when i got the time.
-
Ok -- great!
from amadeus-ws-client.
Completed and it works, thanks for the help!
It's an ugly implementation but here it is for anyone else wondering how to do it:
BASH/CMD
cd <your_dir_with_amabnl_lib>
composer require monolog/monolog
yourFile.php
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
$logName = 'requestResponse';
$logSrc = $conf->logger->src; // ie /var/www/amabnl/logs/
$log = new Logger('log');
$log->pushHandler(new StreamHandler($logSrc . $logName .'.log', Logger::INFO));
// ns
use Amadeus\Client;
use Amadeus\Client\Params;
use Amadeus\Client\Result;
use Amadeus\Client\RequestOptions\CommandCrypticOptions;
// amadeus default params
$params = new Params([
'sessionHandlerParams' => [
'soapHeaderVersion' => Client::HEADER_V4, // default, can be omitted.
'wsdl' => $conf->amadeus->wsdl,
'stateful' => true, // Enabled by default. Stateful needed for transactions etc
'logger' => $log, // use log object previously created
'authParams' => [
'officeId' => $conf->amadeus->officeId, // The Amadeus Office Id you want to sign in to - must be open on your WSAP.
'userId' => $conf->amadeus->user, // Also known as 'Originator' for Soap Header 1 & 2 WSDL's
'passwordData' => base64_encode($conf->amadeus->pass), // **base 64 encoded** password
]
],
'requestCreatorParams' => [
'receivedFrom' => $conf->amadeus->company, // The "Received From" string that will be visible in PNR History
]
]);
$client = new Client($params);
// DO STUFF ...
from amadeus-ws-client.
Good to hear! Then I'm closing this issue and the follow-up for the responseXml will be handled in the other issue.
from amadeus-ws-client.
Added a sample to create a logfile in the docs: https://github.com/amabnl/amadeus-ws-client/blob/master/docs/how-to.rst#logging-request-and-response
from amadeus-ws-client.
Related Issues (20)
- How can I make requests to be stateful? HOT 2
- 11 | Session HOT 5
- Air_MultiAvailability excluded connections question HOT 3
- ADD CONTACT IN SSR CTCM CTCE HOT 1
- Ticket_IgnoreRefund
- Ticket_IgnoreRefund : DOMDocument::loadXML() Empty string supplied as input HOT 2
- How to add Passengers Title
- Create Form of payment after PNR_AddMultiElements
- Ticket_RebookAndRepricePNR
- Booking seat for stops [PNR_AddMultiElements].
- psr/log version conflict with Laravel 10 HOT 2
- 11|Session - Hosting based restrictions HOT 1
- Ticket_CreateTSTFromPricing not group TST by type passenger
- airRetrieveSeatMap error processingLevel 1
- How to add Tax Info in MPTB request HOT 1
- Help for startup
- Processing ERROR for Rail PNR in Amadeus
- PNR status issue
- Unable to install Amadeus library HOT 1
- Fxq HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amadeus-ws-client.