Skip to content

Commit 13dd9c1

Browse files
committed
Adding documentation
1 parent ddf1c71 commit 13dd9c1

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

Logging.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
[![Generic badge](https://img.shields.io/badge/LOGGING-NEW-GREEN.svg)](https://shields.io/)
2+
3+
# Logging in CyberSource REST Client SDK (PHP)
4+
5+
Since v0.0.24, a new logging framework has been introduced in the SDK. This new logging framework makes use of Monolog, and standardizes the logging so that it can be integrated with the logging in the client application. The decision to use Monolog for building this logging framework has been taken based on benchmark studies that have been made on various logging platforms supported for PHP.
6+
7+
[One such study](https://www.loggly.com/blog/benchmarking-php-logging-frameworks-which-is-fastest-and-most-reliable-2/) performed benchmarking of five logging frameworks on the market — native PHP logging, Monolog, KLogger, and Apache Log4php. In this study,
8+
9+
> _For a more complete framework, Monolog seems to be the more well-rounded option, particularly when considering remote logging via TCP/IP._
10+
11+
## Monolog Configuration
12+
13+
In order to leverage the new logging framework, the following configuration settings may be added to the merchant configuration as part of **`LogConfiguration`**:
14+
15+
* $enableLog
16+
* $debugLogFile
17+
* $errorLogFile
18+
* $logDateFormat
19+
* $logFormat
20+
* $logMaxFiles
21+
* $logLevel
22+
* $enableMasking
23+
24+
In our [sample ExternalConfiguration.php](https://github.com/CyberSource/cybersource-rest-samples-php/blob/master/Resources/ExternalConfiguration.php) file, the following lines have been added to support this new framework
25+
26+
```php
27+
$this->enableLogging = true;
28+
$this->debugLogFile = __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "Log" . DIRECTORY_SEPARATOR . "debugTest.log";
29+
$this->errorLogFile = __DIR__ . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "Log" . DIRECTORY_SEPARATOR . "errorTest.log";
30+
$this->logDateFormat = "Y-m-d\TH:i:s";
31+
$this->logFormat = "[%datetime%] [%level_name%] [%channel%] : %message%\n";
32+
$this->logMaxFiles = 3;
33+
$this->logLevel = "debug";
34+
$this->enableMasking = true;
35+
...
36+
$logConfiguration = new \CyberSource\Logging\LogConfiguration();
37+
$logConfiguration->enableLogging($this->enableLogging);
38+
$logConfiguration->setDebugLogFile($this->debugLogFile);
39+
$logConfiguration->setErrorLogFile($this->errorLogFile);
40+
$logConfiguration->setLogDateFormat($this->logDateFormat);
41+
$logConfiguration->setLogFormat($this->logFormat);
42+
$logConfiguration->setLogMaxFiles($this->logMaxFiles);
43+
$logConfiguration->setLogLevel($this->logLevel);
44+
$logConfiguration->enableMasking($this->enableMasking);
45+
$config->setLogConfiguration($logConfiguration);
46+
```
47+
48+
### Important Notes
49+
50+
The variable `enableMasking` needs to be set to `true` if sensitive data in the request/response should be hidden/masked.
51+
52+
Sensitive data fields are listed below:
53+
54+
* Card Security Code
55+
* Card Number
56+
* Any field with `number` in the name
57+
* Card Expiration Month
58+
* Card Expiration Year
59+
* Account
60+
* Routing Number
61+
* Email
62+
* First Name & Last Name
63+
* Phone Number
64+
* Type
65+
* Token
66+
* Signature

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -176,5 +176,13 @@ For example:
176176

177177
The [API Reference Guide](https://developer.cybersource.com/api/reference/api-reference.html) provides examples of what information is needed for a particular request and how that information would be formatted. Using those examples, you can easily determine what methods would be necessary to include that information in a request using this SDK.
178178

179+
### Logging
180+
181+
[![Generic badge](https://img.shields.io/badge/LOGGING-NEW-GREEN.svg)](https://shields.io/)
182+
183+
Since v0.0.24, a new logging framework has been introduced in the SDK. This new logging framework makes use of Monolog, and standardizes the logging so that it can be integrated with the logging in the client application.
184+
185+
More information about this new logging framework can be found in this file : [Logging.md](Logging.md)
186+
179187
[packagist_badge]: https://img.shields.io/packagist/v/cybersource/rest-client-php.svg
180188
[packagist]: https://packagist.org/packages/cybersource/rest-client-php

0 commit comments

Comments
 (0)