Skip to content

Commit 0dbb895

Browse files
committed
README - Section for logging details added.
Section for logging details added. Necessary information about logging like defining regexes in configuration, file paths, and logging and masking usage is mentioned.
1 parent b1dd8b2 commit 0dbb895

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,30 @@ else
126126
}
127127
```
128128

129+
## Logging
130+
131+
SDK generates log with masking for sensitive data like credit card, expiration dates. The provided levels for logging are
132+
`debug`, `info`, `warn`, `error`. Add ````use \net\authorize\util\LogFactory;````. Logger can be initialized using `$logger = LogFactory::getLog(get_class($this));`
133+
The default log file `phplog` gets generated in the current folder. The subsequent logs are appended to the same file, unless the execution folder is changed, and a new log file is generated.
134+
135+
### Usage Examples
136+
- Logging a string message `$logger->debug("Sending 'XML' Request type");`
137+
- Logging xml strings `$logger->debug($xmlRequest);`
138+
- Logging using formatting `$logger->debugFormat("Integer: %d, Float: %f, Xml-Request: %s\n", array(100, 1.29f, $xmlRequest));`
139+
140+
### Customizing Sensitive Tags
141+
A local copy of [AuthorizedNetSensitiveTagsConfig.json](/lib/net/authorize/util/ANetSensitiveFields.php) gets generated when code invoking the logger first gets executed. The local file can later be edited by developer to re-configure what is masked and what is visible (*Do not edit the json in sdk*).
142+
- For each element of the `sensitiveTags` array,
143+
- `tagName` field corresponds to the name of the property in object, or xml-tag that should be hidden entirely ( *XXXX* shown if no replacement specified ) or masked (e.g. showing the last 4 digits of credit card number).
144+
- `pattern`[<sup>[Note]</sup>](#regex-note) and `replacement`[<sup>[Note]</sup>](#regex-note) can be left `""`, if the default is to be used (as defined in [Log.php](/lib/net/authorize/util/Log.php)). `pattern` gives the regex to identify, while `replacement` defines the visible part.
145+
- `disableMask` can be set to *true* to allow the log to fully display that property in an object, or tag in a xml string.
146+
- `sensitiveStringRegexes`[<sup>[Note]</sup>](#regex-note) has list of credit-card regexes. So if credit-card number is not already masked, it would get entirely masked.
147+
- Take care of non-ascii characters (refer [manual](http://php.net/manual/en/regexp.reference.unicode.php)) while defining the regex, e.g. use
148+
`"pattern": "(\\p{N}+)(\\p{N}{4})"` instead of `"pattern": "(\\d+)(\\d{4})"`. Also note `\\` escape sequence is used.
149+
150+
**<a name="regex-note">Note</a>:**
151+
**For any regex, no starting or ending '/' or any other delimiter should be defined. The '/' delimiter and unicode flag is added in the code.**
152+
129153
## Testing
130154

131155
Integration tests for the AuthorizeNet SDK are in the `tests` directory. These tests

0 commit comments

Comments
 (0)