You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Section for logging details added.
Necessary information about logging like defining regexes in configuration, file paths, and logging and masking usage is mentioned.
Copy file name to clipboardExpand all lines: README.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -126,6 +126,30 @@ else
126
126
}
127
127
```
128
128
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);`
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
+
**<aname="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
+
129
153
## Testing
130
154
131
155
Integration tests for the AuthorizeNet SDK are in the `tests` directory. These tests
0 commit comments